gpt4 book ai didi

arrays - ElasticSearch读取数组上的元素

转载 作者:行者123 更新时间:2023-12-03 01:07:51 25 4
gpt4 key购买 nike

我正在使用Elasticsearch,目前我有这样的结构

{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "999999",
"_type": "content",
"_id": "NmYTku",
"_score": 1,
"_source": {
"internal_id": "NmYTk4",
"external_id": "Ga_UI502",
"
"images": [
{
"uri_id": "2939306",
"url": "14mast_head.jpg",
"type": "Masthead",
"orientation": "Landscape",
"x_resolution": 3280,
"y_resolution": 1480
},
{
"uri_id": "Galavision/POST_poster/2939306",
"url": "140603_29un_erro_poster.jpg",
"type": "Poster",
"orientation": "Portrait",
"x_resolution": 720,
"y_resolution": 405
},
{
"uri_id": "Galavision/POST_poster_title/2939306",
"url": "140603_29un_erro_poster_title.jpg",
"type": "PosterWithTitle",
"orientation": "Portrait",
"x_resolution": 924,
"y_resolution": 518
},
{
"uri_id": "Galavision/POST_poster_cover/2939306",
"url": "140603_29poster_cover.jpg",
"type": "Poster",
"orientation": "Landscape",
"x_resolution": 600,
"y_resolution": 868
}
]
}
}
]
}
}

我想知道如何从数组中仅获取一个值,例如
我只希望在“风景”上具有定向的图像,然后键入Poster。我尝试使用此查询,但仅返回所有图像元素。
{
"query": {
"filtered": {
"filter": { "term":{"_id":"NmYTku"} }
}
},
"_source": ["images"]
}

我不知道如何对元素进行过滤

最佳答案

您是否为图像使用嵌套字段或子字段?如果没有,该文档实际上将被索引为:

...
images.uri_id = [1, 2, 3, 4, etc..]
images.url = [1, 2, 3, 4, etc..]
images.type = [1, 2, 3, 4, etc..]
...

因此各个元素之间的区别消失了。尝试阅读以下内容:
http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/complex-core-fields.html

如果您不需要查询,为什么不过滤掉您喜欢的客户端呢?

关于arrays - ElasticSearch读取数组上的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24638071/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com