# Fields, keywords and text

**URL:** <https://discuss.elastic.co/t/fields-keywords-and-text/282422>\
**Category:** Elasticsearch\
**Created:** [August 25, 2021, 12:18am UTC](https://discuss.elastic.co/t/fields-keywords-and-text/282422 "2021-08-25T00:18:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iLemming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilemming/32/90718_2.png) [@iLemming](https://discuss.elastic.co/u/iLemming)\
**Post date:** [August 25, 2021, 12:18am UTC](https://discuss.elastic.co/t/fields-keywords-and-text/282422/1 "2021-08-25T00:18:38Z")

</div>

I'm dealing with a headache where it seems I can't find the correct set of parameters for the analyzer.

So here's the problem:

I have an index where some fields are type of text and some fields are `"type": "keyword"`.

Let's say I have data like this:

```auto
{
  "title": "quick lazy dog" // text
  "source": "internet" //keyword
}

```

Now, when I search using a query:

```auto
"query_string": {
    "query": "quick lazy dog",
    "default_operator": "and",
    "fields": ["title", "source"],
}

```

It works. But then, if I add a "stop" word. Like so:

```auto
"query_string": {
    "query": "the quick lazy dog",
    "default_operator": "and",
    "fields": ["title", "source"],
}

```

It doesn't work anymore. It won't remove "the". And the issue it seems that there are different types of fields mixed. Because when I do it like this:

```auto
"query_string": {
    "query": "the quick lazy dog",
    "default_operator": "and",
    "fields": ["title", "some_other_text_field"],
}

```

It works just fine.

I've been trying to configure custom analyzers, tweaking filters and tokenizer params, but I can't get it right.  
Someone please help me!

Ah, btw. I'm trying to get it right for ES 5.6  
we're currently migrating to ES 7, I think the semantics would slightly differ, but right now I need to solve it primarily for 5.6

---

<div class="post-metadata">

**Author:** ![hunsw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hunsw/32/93637_2.png) [@hunsw](https://discuss.elastic.co/u/hunsw)\
**Post date:** [August 25, 2021, 11:37am UTC](https://discuss.elastic.co/t/fields-keywords-and-text/282422/2 "2021-08-25T11:37:40Z")

</div>

I'm on 7.12 (until evening when I will be on 8.0 😃 ), but if I interpret it right, your query is basically (let's narrow it down to 2 words only, **quick dog** ):

```auto
(title:quick OR source:quick) AND (title:dog OR source:dog)

```

When you add `the` or any other word not appearing in your `title` field, it turns into

```auto
(title:quick OR source:quick) AND (title:dog OR source:dog) AND (title:someword OR source:someword)

```

There may be some differences due to your `source` field being a keyword, but what I suggest is using the explicit query in the `query` field so it's clear for everyone (for you too) what is the real query you are executing.

So for your example, you could search for:  
`query: "title:(the OR quick OR dog) AND source:\"The Quick Dog\""`  
(OR is the default, so `the quick dog` works equally fine.)

Relevant doc: [Query string query | Elasticsearch Guide [7.14] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#query-string-multi-field)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 22, 2021, 11:38am UTC](https://discuss.elastic.co/t/fields-keywords-and-text/282422/3 "2021-09-22T11:38:11Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
