簡體   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