Skip to content

Latest commit

 

History

History
40 lines (36 loc) · 812 Bytes

File metadata and controls

40 lines (36 loc) · 812 Bytes

Query Dsl Term

  • Frequently used to match on exact value
  • An equivalent of Sql statement:
    select * from orders where id = "1"
    
  • Example
    curl -XPOST 'localhost:9200/orders/_search?pretty=true' \
    -H 'content-type:application/json' \
    -d '{
    "query" : {
      "term": {
        "id": "1"
      }
    }
    }'
    
  • Note that 'from orders' part of the statement is part of the Url rather than body
  • Capable of handling numbers, booleans, dates, and text
  • Often used as a filter rather than for scoring, commonly used with constant_score:
    curl -XPOST 'localhost:9200/orders/_search?pretty=true' \
    -H 'content-type:application/json' \
    -d '{
    "query" : {
      "constant_score" : { 
        "filter" : {
          "term": {
            "id": "1"
          }
        }
      }
    }
    }'