Skip to main content

Match Phrase Query

The MatchPhrase query analyzes the text and creates a phrase query out of the analyzed text.

In order to use the MatchPhrase query import the following:

import zio.elasticsearch.query.MatchPhraseQuery
import zio.elasticsearch.ElasticQuery._

You can create a MatchPhrase query using the matchPhrase method this way:

val query: MatchPhraseQuery = matchPhrase(field = "stringField", value = "test")

You can create a type-safe MatchPhrase query using the matchPhrase method this way:

val query: MatchPhraseQuery = matchPhrase(field = Document.stringField, value = "test")

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

val queryWithBoost: MatchPhraseQuery = matchPhrase(field = Document.stringField, value = "test")g.boost(2.0)

You can find more information about MatchPhrase query here.