[英]Failed to create query: Can only use phrase prefix queries on text fields - not on [customer_name] which is of type [keyword]
[英]SearchBox Multi Match Query with type best_fields and NOT phrase_prefix
我正在使用searchkit 2.2.0中的SearchBox ,并希望将具有选项类型best_fields的 多匹配查询 转换为elasticsearch 。
如果我设置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"]}/>
如果我设置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" }}/>
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.