Skip to content

Latest commit

 

History

History
36 lines (35 loc) · 710 Bytes

QueryDslTerms.md

File metadata and controls

36 lines (35 loc) · 710 Bytes

Query Dsl Terms

  • Used to match on any of the values
  • Equivalent of sql statement:
select * from orders where id = "1" or id = "2"
  • Example
curl -XPOST 'localhost:9200/orders/orders/_search?pretty=true' \
  -H 'content-type:application/json' \
  -d '{
  "query" : {
    "terms": {
      "id": [ "1", "2"]
    }
  }
}'
  • Can be extended with lookup - where list of values is a reference to a doc:
curl 'localhost:9200/orders/orders/_search?pretty=true' \
  -H 'content-type:application/json' \
  -d '{
  "query" : {
    "terms": {
      "id": {
        "index" : "lateorders",
        "type" : "lateorders",
        "id" : "2018-01-01",
        "path" : "ids"
      }
    }
  }
}'