Filter query gives empty result

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 .

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

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"  }}
      ]
    }
  }
}

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

    "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.

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

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