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?

1
  • 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? Commented Dec 19, 2017 at 8:25

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.