Multi Match Query
The MultiMatch query builds on the match query to allow multi-field queries.
In order to use the MultiMatch query import the following:
import zio.elasticsearch.query.MultiMatchQuery
import zio.elasticsearch.ElasticQuery._
You can create a MultiMatch query without specifying fields using the multiMatch method this way:
val query: MultiMatchQuery = multiMatch(value = "test")
If you want to change the fields that will be searched, you can use the fields method:
val query: MultiMatchQuery = multiMatch(value = "test").fields("stringField1", "stringField2")
If you want to change the fields that will be searched, you can use the fields method with the type-safe parameters this way:
val query: MultiMatchQuery = multiMatch(value = "test").fields(Document.stringField1, Document.stringField2)
If you want to change the boost, you can use the boost method:
val queryWithBoost: MultiMatchQuery = multiMatch(value = "test").fields(Document.stringField1, Document.stringField2).boost(2.2)
If you want to change the minimum_should_match, you can use the minimumShouldMatch method:
val queryWithMinimumShouldMatch: MultiMatchQuery = multiMatch(value = "test").fields(Document.stringField1, Document.stringField2).minimumShouldMatch(2)
If you want to change the type, you can use the matchingType method:
import zio.elasticsearch.query.MultiMatchType._
val queryWithType: MultiMatchQuery = multiMatch(value = "test").fields(Document.stringField1, Document.stringField2).matchingType(MostFields)
You can find more information about MultiMatch query here.