Upper case and lower case string giving different results for filter

So I have this query,
{ "query": { "bool": { "must": [ { "match": { "title": "communication"}} ], "filter": [ { "term": { "survey": "general" }} ] } } }
Now, it gives me exactly one result. The survey field has

General communcation Society

so if i string in my filter term to General , it does not return any hits. and also if I type in while General communication Society, it does not return any result.
Any explanation why and how to fix it.
Thanks

decodeit,

The field value in the document, "General communcation Society", gets analyzed, probably by the default analyzer (unless you have specified otherwise in your mapping). You may note that it includes lowercase of all the tokens, so one of the indexed tokens for that document is "general".

Now, when using a term filter, the value is not analyzed, just the raw value is compared. So when you use "general" it matches, but "General" does not. When you provide a term search for the entire phrase, it's not even tokenized, so will only return a doc where the exact phrase has been tokenized - none, because the indexer only stored the fully analyzed tokens.

If you instead use match, then it will be analyzed the same way the indexed documents field was analyzed, and both of those will match.

I tried using like this:
"filter": [ { "multi_match": { "query": "General Social Survey", "fields": "survey.title.en" } } ]

is this the best approach.
Also I am looking in to passing an array for query in filter.
Thanks

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