这里,主文档有几个嵌套对象(标签),每个标签都有几个嵌套对象(事件)。
我想获取类型为 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:查询嵌套对象属性和父属性
发布评论