您实际需要的是一种分析输入数据的不同方法。参见下文,这应该是最终解决方案的起点(因为您需要考虑查询和数据分析的全部要求)。使用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" } } ] } }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)