本文介绍了从elasticsearch检索多值数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很难在索引中显示该方面.基本上,我想在单独的数组中获取特定方面的详细信息,例如公司"
我尝试了很多查询,但是都在facet数组下获取了整个facet.如何在facet数组中仅获取特定facet
我的索引是 https://gist.github.com/4015817
请帮助我.我被困在这里
解决方案
考虑到您的数据结构有多复杂,提取此信息的简单方法可能是使用脚本字段:
curl"localhost:9200/index/doc/_search?pretty = true" -d'{询问" : {"match_all":{}},"script_fields":{"entity_facets":{"script":结果= []; foreach(facet:_source.Categories.Types.Facets){if(facet.entity == entity)result.add(facet);}结果",参数":{"entity":"Country"}},"first_facet":{"script":"_source.Categories.Types.Facets [0]"}}}'
I have trouble getting the facet in my index.Basically I want to get the details of particular facet say "Company" in a separate array
I tried many queries but it all get entire facet under facet array .How can I get only particular facet in a facet array
My index is https://gist.github.com/4015817
Please help me .I am badly stuck here
解决方案
Considering how complex your data structure is, the simples way to extract this information might be using script fields:
curl "localhost:9200/index/doc/_search?pretty=true" -d '{
"query" : {
"match_all" : {
}
},
"script_fields": {
"entity_facets": {
"script": "result=[];foreach(facet : _source.Categories.Types.Facets) {if(facet.entity==entity) result.add(facet);} result",
"params": {
"entity": "Country"
}
},
"first_facet": {
"script": "_source.Categories.Types.Facets[0]"
}
}
}'
这篇关于从elasticsearch检索多值数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!