如何在布尔查询中提升索引查询

如何在布尔查询中提升索引查询,第1张

如何在布尔查询中提升索引查询

您实际需要的是一种分析输入数据的不同方法。参见下文,这应该是最终解决方案的起点(因为您需要考虑查询和数据分析的全部要求)。使用ES进行搜索不仅涉及查询,还涉及如何
构造和准备数据

这个想法是您希望对数据进行分析,以便

belden cable
保持原样。随着映射
"name": {"type":"string"}
standard
正在使用分析,这意味着术语的索引列表是
belden
cable
。你真正需要的是什么[
beldencable
belden
cable
。因此,我考虑过建议使用
shingles
令牌过滤器。

DELETE /addresssPUT /addresss{  "settings": {    "analysis": {      "analyzer": {        "analyzer_shingle": {          "tokenizer": "standard",          "filter": [ "standard", "lowercase", "shingle"          ]        }      }    }  },  "mappings": {    "test": {      "properties": {        "name": {          "type": "string",          "analyzer": "analyzer_shingle"        }      }    }  }}DELETE /customersPUT /customers{  "settings": {    "analysis": {      "analyzer": {        "analyzer_shingle": {          "tokenizer": "standard",          "filter": [ "standard", "lowercase", "shingle"          ]        }      }    }  },  "mappings": {    "test": {      "_all": {        "analyzer": "analyzer_shingle"      }    }  }}POST /addresss/test/_bulk{"index":{}}{"name": "belden cable"}{"index":{}}{"name": "belden cable yyy"}{"index":{}}{"name": "belden cable xxx"}{"index":{}}{"name": "belden bla"}{"index":{}}{"name": "cable bla"}POST /customers/test/_bulk{"index":{}}{"field1": "belden", "field2": "cable"}{"index":{}}{"field1": "belden cable yyy"}{"index":{}}{"field2": "belden cable xxx"}{"index":{}}{"field2": "belden bla"}{"index":{}}{"field2": "cable bla"}GET /addresss,customers/test/_search{  "query": {    "bool": {      "should": [        {          "indices": { "indices": [   "addresss" ], "query": {   "bool": {     "should": [       {         "match_phrase_prefix": {"name": "BELDEN CABLE"         }       },       {         "match_phrase_prefix": {"name": "BELDEN"         }       },       {         "match_phrase_prefix": {"name": "CABLE"         }       }     ]   } }, "no_match_query": "none"          }        },        {          "indices": { "indices": [   "customers" ], "query": {   "bool": {     "should": [       {         "match_phrase_prefix": {"_all": "BELDEN CABLE"         }       },       {         "match_phrase_prefix": {"_all": "CABLE"         }       },       {         "match_phrase_prefix": {"_all": "BELDEN"         }       }     ]   } }, "no_match_query": "none"          }        }      ]    }  }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4907792.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存