Skip to main content

Terms Query

The Terms query returns documents that contain one or more exact terms in a provided field. This query is the same as the Term query, except you can search for multiple values.

In order to use the Terms query import the following:

import zio.elasticsearch.query.TermsQuery
import zio.elasticsearch.ElasticQuery.terms

You can create a Terms query using the terms method this way:

val query: TermsQuery = terms(field = "name", "a", "b", "c")

You can create a type-safe Terms query using the terms method this way:

val query: TermQuery = terms(field = Document.name, "a", "b", "c")

If you want to change the boost, you can use boost method:

val queryWithBoost: TermsQuery = terms(field = "name", "a", "b", "c").boost(2.0)

You can find more information about Terms query here.