Elasticsearch – Advance Query [DSL Query Context]

DSL Query Context

The exists checks if the field email exists under the professor not that if there is any value exists or not.

Under the “must” clause all the queries should be true. This is part of the query DSL {domain specific language). Under a must, we can put multiple match data. And must keyword goes under a “bool” keyword.

Here we are specifying that the professor.name must not be “bill”.

The should keyword is like, it would be good to have the given field and data. They should don’t take precedence. So elasticsearch almost ignore it. To make it notice should we can do the following.

This minimum_should_match means at least one should match. It enforces that the condition inside of them should better also be true. And here we are asking that one condition inside the should be true.

This is a multi_match verb, in the given fields we can match the given query, anyone field match will be ok for this method.

match_phrase is going to match a part of a sentence. Match phrase takes each word as a token and then searches for it in the document. An unfinished word will case you no data found.

match_phrase_prefix will get the result, partial tokens can be matched by match_phrase_prefix.

The gte means “greater than or equal to” and lte means “less than or equal to”. The range query we are using here is to determine students enrolled between 10 to 20.

The complex mixture of match and range query.