I am using SearchBox from searchkit 2.2.0 and would like to make Multi Match Query with option type best_fields to elasticsearch.
If I set prefixQueryFields attribute, query is Multi Match as I want, but type is phrase_prefix gets me non prefered results. QueryAccessor.ts->this.options.prefixQueryFields->type:"phrase_prefix"
<SearchBox autofocus={true} searchOnChange={true} prefixQueryFields={["fileName^3", "path", "attachment.content", "attachment.author", "attachment.title"]}/>
If I set prefixQueryOptions attribute, to avoid type phrase_prefix, query become just simple_query_string. Maybe I made a mistake here, when I set prefixQueryOptions object.
<SearchBox autofocus={true} searchOnChange={true} prefixQueryOptions={{ "fields" : [ "fileName^3", "path", "attachment.content", "attachment.author", "attachment.title" ], "type": "best_fields" }}/>
queryBuilder can provide more flexible logic than prefixQueryFields . https://blog.searchkit.co/searchkit-0-9-23d78568d219
const customQueryBuilder = (query, options) => { return { "multi_match": { "query": query, "fields" : [ "fileName^3", "path", "attachment.content", "attachment.author", "attachment.title" ], "type": "best_fields" } } } <SearchBox autofocus={true} searchOnChange={true} queryOptions={{analyzer:"standard"}} queryFields={["fileName^3","path","attachment.content","attachment.author","attachment.title","attachment.fileExtension"]} queryBuilder={customQueryBuilder} />
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.