Congratulations, you now understand the fundamentals of the Elasticsearch query DSL. As next steps, you should explore the following queries:
-
The
range
query allows you to find documents that contain terms within a provided range. For example, if each recipe had arating
, you could add a clause to only return recipes in whichrating
is greater than or equal to4
.GET recipes/_search { "query": { "range": { "rating": { "gte": 4 } } } }
-
The
match_phrase
query allows you to find documents that contain multiple terms in the same order. For example, you could search forolive oil
in the ingredients and only get back documents that containolive oil
as an ingredient (not onlyolive
oroil
).GET recipes/_search { "query": { "match_phrase": { "ingredients": "olive oil" } } }
-
The
more_like_this
query allows you to find documents that are "like" a given set of documents. For example, you could find recipes that are similar to other recipes you like.# imagine you like both recipes 152 and 28322 GET recipes/_doc/152 GET recipes/_doc/28322 GET recipes/_search { "query": { "more_like_this": { "fields": [ "ingredients" ], "like": [ { "_index": "recipes", "_id": "152" }, { "_index": "recipes", "_id": "28322" } ], "min_term_freq": 1, "max_query_terms": 12 } } }
If you are also interested in slicing and dicing your data, you should take the Elasticsearch Aggregations in 15 Minutes course.