0

我正在研究searchkit,我正在尝试在搜索框中获取部分搜索的结果,但是当数据库中匹配完整的文本时,结果可用。有没有办法实现这一点,我已经尝试过 queryOptions={{analyzer : "patrial", default_operator:"AND", allow_leading_wildcard: true, analyze_wildcard: true}} 在我的搜索框标签中,但搜索时出错。这是我的搜索框代码:

        ** <SearchBox
                    translations={{"searchbox.placeholder":" "}}
                    autofocus={true}
                                searchOnChange={true}
                                // queryOptions= 
                    {{default_operator:"AND"}}
                                queryOptions={{analyzer: "patrial", 
                     default_operator:"AND", allow_leading_wildcard: 
                       true, analyze_wildcard: true}}

                                />**
4

1 回答 1

0

尝试在queryBuilder组件中使用自定义查询,SearchBox如:此答案

const customQueryBuilder = (query, options) => {
  return {
    "multi_match": {
      "query": query,
      "fields" : [ "field1", "field2", "field3"]
  }
  }
}

<SearchBox queryBuilder={customQueryBuilder} autofocus={true}  queryOptions={{analyzer:"autocomplete", searchOnChange={true} prefixQueryFields={["field1", "field2", "field3"]}  />
于 2018-05-14T18:48:01.100 回答