大佬教程收集整理的这篇文章主要介绍了加入elasticsearch索引,同时匹配嵌套/内部对象中的字段,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
curl -XdeletE "http://example.com:9200/currencylookup/" curl -XdeletE "http://example.com:9200/currency/"
@H_874_6@
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" }] }'
@H_874_6@
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" }'
@H_874_6@
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" } } } } }'
@H_874_6@
# 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" : { "@R_7_10586@l" : 5, "successful" : 5, "Failed" : 0 }, "hits" : { "@R_7_10586@l" : 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" } } ] } }
@H_874_6@
大写字母是罪魁祸首。
您会看到 是大写字母,因此匹配失败,并且即使在 也没有查找,因为它是大写字母。
交叉匹配值必须为小写字母或数字,例如
例如:
我正在尝试通过使用术语过滤器查找来加入2个Elasticsearch索引。我提到了http://www.elasticsearch.org/blog/terms-
filter-lookup/和http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-
dsl-terms-filter。
html。这些示例在诸如“ followers”:[“ 1”,“
3”]之类的字段数组上查找,并且join对于类似数据也可以正常工作。
我的要求是在对象数组中加入一个字段。当我将上述示例扩展为包括对象数组时,我的查询失败。以下是样本数据:
PUT /users/user/2 { "followers" : [ { "userId":"1","username":"abc","LOCATIOn":"xyz" },{ "userId":"3","username":"def","LOCATIOn":"xyz" } } ] } PUT /tweets/tweet/1 { "user" : "2" } PUT /tweets/tweet/2 { "user" : "1" }
@H_874_6@我现在正在尝试查找由用户2的追随者创建的推文
POST /tweets/_search { "query" : { "filtered" : { "filter" : { "terms" : { "user" : { "index" : "users","type" : "user","id" : "2","path" : "followerS.UserId" },"_cache_key" : "user_2_friends" } } } } }
@H_874_6@我的搜索结果为0的上述查询。我也尝试了2种其他方法:1)在映射过程中将跟随者对象声明为嵌套对象,并在查询中使用“嵌套”;
2)尝试在将路径指定为“跟随者”之后为followerS.UserId添加匹配查询。没有产生结果。术语过滤查询是否支持对象数组?解决我的问题的任何指示将大有帮助
以上是大佬教程为你收集整理的加入elasticsearch索引,同时匹配嵌套/内部对象中的字段全部内容,希望文章能够帮你解决加入elasticsearch索引,同时匹配嵌套/内部对象中的字段所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。