Elasticsearch: querying on both nested object properties and parent properties

六月ゝ 毕业季﹏ 提交于 2019-12-23 01:12:22

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/35550702/elasticsearch-querying-on-both-nested-object-properties-and-parent-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!