我正在使用 ReactiveSearch 来支持购物网站上的查询。但是,如果我搜索“tops”,则查询匹配包含“topshop”之类的单词的描述,并且这些结果的排名高于仅包含“tops”的描述。如何禁用所有前缀匹配?
我正在使用具有以下配置的 ReactiveSearch 库:
const DataSearchProps = {
componentId: 'q',
dataField: ['title', 'filter_color', 'category', 'brand', 'description', 'size_type'],
fieldWeights: [1000, 500, 100, 50, 5, 5, 1, 10],
placeholder: 'Search 1M+ Clothes...',
iconPosition: 'right',
queryFormat: 'and',
fuzziness: 'AUTO',
autosuggest: false,
autoFocus: true,
URLParams: true,
className: 'searchbox',
name: 'q',
}
这是一个示例查询
{
"query":{
"bool":{
"must":[
{
"bool":{
"must":[
{
"bool":{
"should":[
{
"multi_match":{
"query":"tops",
"fields":[
"allparel_tags^1000",
"title^500",
"brand^5",
"raw_category^5",
"description^1",
"size_type^50"
],
"type":"cross_fields",
"operator":"and"
}
},
{
"multi_match":{
"query":"tops",
"fields":[
"allparel_tags^1000",
"title^500",
"brand^5",
"raw_category^5",
"description^1",
"size_type^50"
],
"type":"phrase_prefix",
"operator":"and"
}
}
],
"minimum_should_match":"1"
}
},
{
"exists":{
"field":"raw_category.keyword"
}
},
{
"terms":{
"condition.keyword":[
"new"
]
}
}
]
}
}
]
}
},
"size":20,
"aggs":{
"condition.keyword":{
"terms":{
"field":"condition.keyword",
"size":100,
"order":{
"_count":"desc"
}
}
}
},
"_source":{
"includes":[
"*"
],
"excludes":[
]
},
"from":0,
"sort":[
{
"_score":{
"order":"desc"
}
}
]
}
由于似乎 ElasticSearch 默认情况下不进行前缀匹配,我对为什么会发生前缀匹配感到困惑。任何帮助表示赞赏!