1

My problem

Consider the following query:

"query": {
  "query_string": {
    "query: "WORD_A WORD_B",
    "default_operator": "AND"
  }
}

I have this query in one of our systems, and I wonder whether the query is exact. By exact I mean that only documents with WORD_A and WORD_B should return, but never documents with just one word, similar words or no matching word at all.

What have I tried

RTFM. Perhaps I'm reading the wrong page, but I did not find a reference to this question.

Environment

Elastic 5.6.3.

My question

Is the abovememtioned query exact, meaning that it will term only documents that strictly match the query?

Adam Matan
  • 128,757
  • 147
  • 397
  • 562
  • Sorry, but I think the link you posted is wrong (although I'm not sure exactly what should it point to). May you please also tell if you tried the query? Does it return you documents with `word_a` or `word_b` only? – Nikolay Vasiliev Dec 19 '17 at 08:25

1 Answers1

1

Yes and no. It really depends on your ES analyzer that has been used for the field. If you are using default one then - yes, except your query would also match lower case terms "word_a word_b". If you are using custom one, which is doing tokenization/filtering/splitting based on "_" the - no.

Some details can be found in How to make query_string search exact phrase in ElasticSearch

IgorDiy
  • 919
  • 1
  • 12
  • 25