I hope to perform this query using elastic search using Java API. For the fuzzy query, how do I get the "prefix_length" argument?
Query:
{"query":{"bool":{"should":[
{"fuzzy":{"object.name":{"value":"appl", "max_expansions":"1", "prefix_length" : 3}}},
{"prefix":{"object.name":"appl"}},
{"term":{"object.name":"appl"}}
]}}}
Java API:
QueryBuilder result = QueryBuilders.boolQuery()
.minimumNumberShouldMatch(1)
.should(QueryBuilders.fuzzyQuery(Company.FIELD_NAME, query)) ...
The documentation here doesn't explain how to get the "prefix_length" argument. Can someone explain? Thanks!
Aha. Can add like this:
should(QueryBuilders.fuzzyQuery(Company.FIELD_NAME, query).maxExpansions(1).prefixLength(query.length() - 1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.