BelowZero
BelowZero

Reputation: 1383

meaning of query in elasticsearch Query DSL

I am trying to understand the semantics of elasticsearch querys. I understand that every query is an object containing the objects "query" and "filter" and maybe some other options. Now inside some leaf query objects one might have a "query" object instead of raw data like text or a number, however this seems to be a different object than the query at the beginning. I tried to understand the documentation but I couldn't find definitions of these two objects.

What I struggle with is that I try to understand querys starting from the leafs and working my way back and looking at it this way, the "query" object inside a leaf is returning some words or data which is used in the leaf query object like "match" as input but this is not what the 'main' query object is doing since this is returning the results of the search.

Are these two objects completely different or are they the same kind of objects and I'm missing the point completely?

Upvotes: 1

Views: 240

Answers (1)

Aaron M. Eshbach
Aaron M. Eshbach

Reputation: 6510

Working from the bottom up might make understanding the DSL difficult. The way the Elasticsearch documentation is laid out is actually pretty helpful for learning the DSL. If you start on this page and just click forward, I think it explains the DSL fairly well.

As for your specific question, the Elasticsearch DSL object structure does use the field name "query" for different purposes. All Request-Body queries (meaning, those that are not Query-String queries) start with the query context. This is the container for the clauses of the query that affect the score. The clauses are the various leaf nodes such as match and term that are used to define the search. The query can also contain a filter context, which contains clauses that further refine the results, but do not affect the score. Some of the clauses have a property named query, such as the Match Query. In this case, the query property is used to define the value being matched.

Upvotes: 1

Related Questions