TermQuery document (Data API 17.8)

A term query matches one (or more) value(s) against one (or more) document field(s). A document is considered a hit if one of the values matches (exactly) with at least one of the given fields. The operator "is" can only take one value, while "one_of" can take multiple. If multiple fields are specified, they are combined using the OR operator.

Elastic only: If used with multiple fields, the query is internally handled as a boolean OR of DisjointMaxQueries (with the dismax matching a value against all fields). The dismax makes sure that a document carrying a single term in multiple fields does not get higher scores than a document matching multiple terms in multiple fields. Example: (id="my_id")
 query: {
     term_query: {
         fields: ["id"],
         operator: "is",
         values: ["my_id"]
     }
 }
 
Example: (id IN ("my_id","other_id"))
 query: {
     term_query: {
         fields: ["id"],
         operator: "one_of",
         values: ["my_id","other_id"]
     }
 }
 
Example: (id=null)
 query: {
     term_query: {
        fields: ["description"],
        operator: "is_null"
    }
 }
 
Example: ((id IN ('generic', 'keyword')) OR (description IN ('generic', 'keyword'))
 query: {
    term_query: {
        fields: ["id", "description"],
        operator: "one_of",
        values: ["generic","keyword"]
    }
 }
 
Property Type Constraints Description
fields [String] itemNullable=false, mandatory=true, minItems=1, nullable=false The document field(s), the value(s) are matched against, combined with the operator.
operator Enum {is, one_of, is_null, is_not_null, less, greater, not_in, neq} mandatory=true, nullable=false Returns the operator to use for the term query.
values [Object] itemNullable=false The values, the field(s) are compared against, combined with the operator.
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. By continuing to use this site you are giving us your consent to do this.