Elasticsearch:查询嵌套对象属性和父属性 [英] Elasticsearch: querying on both nested object properties and parent properties
问题描述
{
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:查询嵌套对象属性和父属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!