Important queries in Query DSL

The following are some of the important queries showing off Query DSL:

  • match_all: Matches all the documents. The default query that runs when nothing is specified. This can be used in conjunction with filter and returns all the documents satisfying the filter condition.
{
“match_all”: {}
}
  • match: Used when you need full text or exact match on any of the fields in the document:
{
“match”: {
“field_name”: “phrase_which_has_to_be_searched”
}
}
  • multi_match: Can be used to match multiple fields in a document. It is like executing multiple match queries:
{
“multi_match”: {
“query”: “phrase_which_has_to_be_searched”,
“fields”: [ “field1”, “field2” ]
}
}
  • range: Used for numbers or date fields that fall in between a particular specified value:
{
"range": {
"field_name": {
"<gt or gte>": 5,
"<lt or lte>": 50
}
}
}
  • term: Used for an exact value search:
{
“term”: {
“field_name”: “search_text”
}
}
  • terms: The same as a term query but allows us to enter multiple search texts, which can be searched on:
{
“terms”: {
“field_name”: [ “search_text1”, “search_text2”, “search_text3” ]
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.131.255