繁体   English   中英

SearchBox多重比对查询,其类型为best_fields,而非NOT_PACK

[英]SearchBox Multi Match Query with type best_fields and NOT phrase_prefix

我正在使用searchkit 2.2.0中的SearchBox ,并希望将具有选项类型best_fields的 多匹配查询 转换elasticsearch

  1. 使用prefixQueryFields时如何设置类型 best_fields
  2. 如何正确设置类型为best_fields的 prefixQueryOptions对象?

如果我设置prefixQueryFields属性,则查询是我想要的“多匹配项”,但类型是“ phrase_prefix”使我得到非期望的结果。 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

如果我设置prefixQueryOptions属性,为避免键入phrase_prefix,查询将变成simple_query_string。 设置prefixQueryOptions对象时,可能在这里犯了一个错误。

 <SearchBox autofocus={true} searchOnChange={true} prefixQueryOptions={{ "fields" : [ "fileName^3", "path", "attachment.content", "attachment.author", "attachment.title" ], "type": "best_fields" }}/> 
结果查询:prefixQueryOptions和simple_query_string

搜索框

多种匹配类型

QueryBuilder的能够比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} /> 

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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