一般来说,如果我们需要在一个嵌套类型中进行一个或多个条件,那么,我们就要进行如下查询:
问题1:
{
"query": {
"bool": {
"must": [{
"nested": {
"query": {
"bool": {
"must": [{
"bool": {
"should": [{
"match": {
"descTags.device": {
"query": "abc"
}
}
}, {
"match": {
"descTags.device": {
"query": "xyz"
}
}
}]
}
}]
}
},
"path": "descTags"
}
}]
}
}
}
上面的查询有一个嵌套,并且在此嵌套类型中有或条件。
在下面用两个嵌套blob表示同一查询:
问题2:
{
"query": {
"bool": {
"must": [{
"bool": {
"should": [{
"bool": {
"must": [{
"nested": {
"query": {
"bool": {
"must": [{
"match": {
"descTags.Modality": {
"query": "abc"
}
}
}]
}
},
"path": "descTags",
}
}]
}
}, {
"bool": {
"must": [{
"nested": {
"query": {
"bool": {
"must": [{
"match": {
"descTags.Modality": {
"query": "xyz"
}
}
}]
}
},
"path": "descTags"
}
}]
}
}]
}
}]
}
}
}
QueRe1和QueRe2在性能上是否有差异,仅仅因为我们有多次嵌套BLB?
编辑1:
根据下面的评论(@卡马尔),我在这里简化了我的问题。
如果布尔操作在“属于同一嵌套类型的属性、只声明一次嵌套类型”的VS“属于同一嵌套类型的属性、声明嵌套类型两次、每次属性一次”之间执行,则性能是否会有所不同。
如下所示:
一。
nested :
or :
attribute1
attribute2
对
2.
or :
nested :
attribute1
nested :
attribute2