Fuzzy Query
The Fuzzy
query returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.
In order to use the Fuzzy
query import the following:
import zio.elasticsearch.query.FuzzyQuery
import zio.elasticsearch.ElasticQuery._
You can create a Fuzzy
query using the fuzzy
method this way:
val query: FuzzyQuery = fuzzy(field = "name", value = "test")
You can create a type-safe Fuzzy
query using the fuzzy
method this way:
val query: FuzzyQuery = fuzzy(field = Document.name, value = "test")
If you want to change the fuzziness
, you can use fuzziness
method:
val queryWithFuzzinessAuto: FuzzyQuery = fuzzy(field = Document.name, value = "test").fuzziness("AUTO")
If you want to change the maxExpansions
, you can use maxExpansions
method:
val queryWithMaxExpansions: FuzzyQuery = fuzzy(field = Document.name, value = "test").maxExpansions(50)
If you want to change the prefixLength
, you can use prefixLength
method:
val queryWithPrefixLength: FuzzyQuery = fuzzy(field = Document.name, value = "test").prefixLength(3)
You can find more information about Fuzzy
query here.