简体   繁体   中英

SearchBox Multi Match Query with type best_fields and NOT phrase_prefix

I am using SearchBox from searchkit 2.2.0 and would like to make Multi Match Query with option type best_fields to elasticsearch.

  1. How to set type best_fields when I use prefixQueryFields ?
  2. How to correctly set prefixQueryOptions object with type best_fields ?

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"]}/> 
结果查询:prefixQueryFields,然后键入phrase_prefix

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" }}/> 
结果查询:prefixQueryOptions和simple_query_string

search-box

multi-match-types

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM