# Filter query gives empty result

**URL:** <https://discuss.elastic.co/t/filter-query-gives-empty-result/75140>\
**Category:** Elasticsearch\
**Created:** [February 15, 2017, 6:36am UTC](https://discuss.elastic.co/t/filter-query-gives-empty-result/75140 "2017-02-15T06:36:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thiru](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@thiru](https://discuss.elastic.co/u/thiru)\
**Post date:** [February 15, 2017, 6:36am UTC](https://discuss.elastic.co/t/filter-query-gives-empty-result/75140/1 "2017-02-15T06:36:43Z")

</div>

I have created a following mapping and I loaded and indexed some documents . I ran the following query but I am not getting any results

I am filtering data on the text field . Does filter works on the text field ?  
If not how to use a filter on the text fields .

```auto
PUT myidex/test
{
   "settings":{
      "analysis":{
         "analyzer":{
            "lowercase_analyzer":{ 
               "type":"custom",
               "tokenizer":"standard",
               "filter":[
                  "lowercase"
               ]
            },
            "generic_description_analyzer": {
               "type": "custom",
               "tokenizer": "icu_tokenizer",
               "filter": [
                  "word_split",
                  "icu_folding",
                  "english_stop"
                ]
            }
         },
         "filter":{
            "english_stop":{
               "type":"stop",
               "stopwords":"_english_"
            },
            "word_split": {
                "type": "word_delimiter",
                "preserve_original": 1
            }
         }
      }
   },
   "mappings":{
      "test":{
        "properties": {
          "weight": {
            "type":"text",
            "analyzer":"lowercase_analyzer", 
            "search_analyzer":"generic_description_analyzer"
            }
,
      "flavour":{
            "type":"text",
            "analyzer":"lowercase_analyzer", 
            "search_analyzer":"generic_description_analyzer"
            }
,
      
      "pack":{
            "type":"text",
            "analyzer":"lowercase_analyzer", 
            "search_analyzer":"generic_description_analyzer"
      },
      "category":{
            "type":"text",
            "index": "not_analyzed"
      },
      
      "brand":{
            "type":"text",
            "index": "not_analyzed"
      }
      ,
      "globalbrandextension":{
            "type":"text",
            "index": "not_analyzed"
      },
      "localbrand":{
            "type":"text",
            "index": "not_analyzed"
      }
       ,
      "productidentifier":{
            "type":"text",
            "index": "not_analyzed"
      }
       
   }
}
}
}

```

My search query

```auto
GET myidex/test/_search
{
  "query": { 
    "bool": { 
      "should": [
        {
          "multi_match": {
            "query": "MYBRAND APPLE JUICE 330ml",
            "fields": ["weight","flavour","pack"]
          }
          
        }
      ]
      
      ,
      "filter": [ 
        
        { "term": { "brand": "MYBRAND" }},
        { "term": { "globalbrandextension": "MYBRAND" }},
        { "term": { "productidentifier": "MYBRAND APPLE JUICE & DRINK" }}
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 15, 2017, 9:06am UTC](https://discuss.elastic.co/t/filter-query-gives-empty-result/75140/2 "2017-02-15T09:06:11Z")

</div>

> [@thiru](#):
>
> ```
> "brand":{
> "type":"text",
> "index": "not_analyzed"
> }
> 
> ```

This is mixing 2.x with 5.x syntax and probably does not do what you think it does. This should probably be:

```auto
    "brand":{
            "type":"keyword"
      }

```

It is also true for all other fields that are mapped the same way.

Also note that when multiple filters are provided, they must all match. Maybe this is what you want, but otherwise you can use a `bool` query with `should` clauses if you just need any of them to match.

---

<div class="post-metadata">

**Author:** ![thiru](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@thiru](https://discuss.elastic.co/u/thiru)\
**Post date:** [February 21, 2017, 2:29pm UTC](https://discuss.elastic.co/t/filter-query-gives-empty-result/75140/3 "2017-02-21T14:29:06Z")

</div>

After I converted to Keyword . Filter's are working thank you very much for the guidance .

---

<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:** [March 21, 2017, 2:29pm UTC](https://discuss.elastic.co/t/filter-query-gives-empty-result/75140/4 "2017-03-21T14:29:21Z")

</div>

Closed on March 21, 2017, 2:29pm UTC

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