Elasticsearch:查询嵌套对象属性和父属性

编程入门 行业动态 更新时间:2024-10-09 22:21:38
本文介绍了Elasticsearch:查询嵌套对象属性和父属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

{started_at:1455088063966, ends_at:1455088131966,tags:[{type:transfer,at:1455088064462,events [type:transfer_processed,at:1455088131981 }] },{at:1455088138232, item:tag,type:info}] }

这里,主文档有几个嵌套对象(标签),每个标签都有几个嵌套对象(事件)。

我想获取类型为 transfer_processed的事件的所有文档发生在60000毫秒之后,类型为 STRONG>。 为此,我需要查询 tags.at , tags.type , tags.events.at 和 tags.events.type 即可。我无法弄清楚如何:我只能设法查询tags.events属性,或只对标签属性进行查询,而不是两者。

解决方案

嵌套对象实际上是在引擎盖下单独的Lucene文档,因此您本质上是尝试将多个文档加入在一起进行比较。不幸的是,这不被Elasticsearch支持。

I have some documents which have nested objects inside nested objects :

{ "started_at": 1455088063966, "ended_at": 1455088131966, "tags": [{ "type": "transfer", "at": 1455088064462, "events": [{ "type": "transfer_processed", "at": 1455088131981 }] }, { "at": 1455088138232, "item": "tag", "type": "info" }] }

Here, the main document has several nested objects (the tags), and for each tag there are several nested objects (the events).

I would like to get all the documents where the events of type transfer_processed occured 60000 milliseconds after the tags of type transfer. For this, I would need to query on both tags.at, tags.type, tags.events.at and tags.events.type. And I can't figure out how: I only manage to query on the tags.events properties, or only on the tags properties, not both.

解决方案

Nested objects are actually separate Lucene documents under the hood, so you are essentially trying to "join" multiple documents together to do your comparisons. Unfortunately, this is not supported by Elasticsearch.

Have a look at this similar question and answer which explain it well.

更多推荐

Elasticsearch:查询嵌套对象属性和父属性

本文发布于:2023-11-05 10:04:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560548.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   嵌套   对象   Elasticsearch

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!