TermQuery document (Data API 23.2)
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 values. If multiple fields are specified, they are combined using the OR operator.
The
less
and greater
operators are not compatible with some search types.
To query based on numeric bounds in those cases, you can use a range filter on a
filtered query.
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] | 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] | The values, the field(s) are compared against, combined with the operator. |
X
OCAPI versions 15.x and 16.x will be retired on March 31, 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.