清除索引(如果有)
curl -XDELETE "http://example.com:9200/currencylookup/"curl -XDELETE "http://example.com:9200/currency/"
创建查找表
curl -XPUT http://example.com:9200/currencylookup/type/2 -d '{ "conv" : [ { "currency":"usd","username":"abc", "location":"USA" }, { "currency":"inr", "username":"def", "location":"India" },{ "currency":"IDR", "username":"def", "location":"Indonesia" }]}'让我们放一些虚拟文档
curl -XPUT "http://example.com:9200/currency/type/USA" -d '{ "amount":"100", "currency":"usd", "location":"USA" }'curl -XPUT "http://example.com:9200/currency/type/JPY" -d '{ "amount":"50", "currency":"JPY", "location":"JAPAN" }'curl -XPUT "http://example.com:9200/currency/type/INR" -d '{ "amount":"50", "currency":"inr", "location":"INDIA" }'curl -XPUT "http://example.com:9200/currency/type/IDR" -d '{ "amount":"30", "currency" : "IDR", "location": "Indonesia" }'是时候检查输出了
curl http://example.com:9200/currency/_search?pretty -d '{ "query" : { "filtered" : { "filter" : { "terms" : { "currency" : { "index" : "currencylookup", "type" : "type", "id" : "2", "path" : "conv.currency" }, "_cache_key" : "currencyexchange" } } } } }'结果
# curl http://example.com:9200/currency/_search?pretty -d '{ "query" : { "filtered" : { "filter" : { "terms" : { "currency" : { "index" : "currencylookup", "type" : "type", "id" : "2", "path" : "conv.currency" }, "_cache_key" : "currencyexchange" } } } } }'{ "took" : 2, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 2, "max_score" : 1.0, "hits" : [ { "_index" : "currency", "_type" : "type", "_id" : "INR", "_score" : 1.0, "_source":{ "amount":"50", "currency":"inr", "location":"INDIA" } }, { "_index" : "currency", "_type" : "type", "_id" : "USA", "_score" : 1.0, "_source":{ "amount":"100", "currency":"usd", "location":"USA" } } ] }}结论
大写字母是罪魁祸首。
您会看到 ‘IDR’ 是大写字母,因此匹配失败,并且即使在 ‘JPY’中 也没有查找,因为它是大写字母。
交叉匹配值必须为小写字母或数字,例如
例如:
- abc
- 1abc



