[英]get fields in Elastic search response in java
I am getting below response from elastic search Can anyone help me in getting only IDs in chain if there are many hits.我得到的来自弹性搜索的响应低于弹性搜索如果有很多点击,任何人都可以帮助我只获取链中的 ID。 eg chainIds = [14,162,123].... if there are 3 hits
例如chainIds = [14,162,123]....如果有3个命中
"hits" : [
{
"_shard" : "******",
"_node" : "******",
"_index" : "e******z",
"_type" : "_doc",
"_id" : "******",
"_score" : 1.0,
"_source" : {
"chain" : {
"website" : "234567.com",
"images" : [
{
"url" : ""
}
],
"name" : "13452e4r5t6y7ui",
"description" : "<p>23456</p>",
"id" : 14
}
}
]
You can do source filtering to get only the id
field in the _source
part您可以进行源过滤以仅获取
_source
部分中的id
字段
Adding a working example添加一个工作示例
Index Data:指数数据:
{
"chain": {
"website": "234567.com",
"images": [
{
"url": ""
}
],
"name": "13452e4r5t6y7ui",
"description": "<p>23456</p>",
"id": 123
}
}
{
"chain": {
"website": "234567.com",
"images": [
{
"url": ""
}
],
"name": "13452e4r5t6y7ui",
"description": "<p>23456</p>",
"id": 162
}
}
{
"chain": {
"website": "234567.com",
"images": [
{
"url": ""
}
],
"name": "13452e4r5t6y7ui",
"description": "<p>23456</p>",
"id": 14
}
}
Search Query:搜索查询:
{
"_source": "chain.id",
"query": {
"match_all": {}
}
}
Search Result:搜索结果:
"hits": [
{
"_index": "66837269",
"_type": "_doc",
"_id": "1",
"_score": 1.0,
"_source": {
"chain": {
"id": 14
}
}
},
{
"_index": "66837269",
"_type": "_doc",
"_id": "2",
"_score": 1.0,
"_source": {
"chain": {
"id": 162
}
}
},
{
"_index": "66837269",
"_type": "_doc",
"_id": "3",
"_score": 1.0,
"_source": {
"chain": {
"id": 123
}
}
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.