通常,如果我们需要在一个嵌套类型内的elasticsearch中执行OR条件,可以说,我们进行如下查询:
查询1:
{
"query": {
"bool": {
"must": [{
"nested": {
"query": {
"bool": {
"must": [{
"bool": {
"should": [{
"match": {
"descTags.device": {
"query": "abc"
}
}
}, {
"match": {
"descTags.device": {
"query": "xyz"
}
}
}]
}
}]
}
},
"path": "descTags"
}
}]
}
}
}
以上查询具有一个嵌套,并且在此一种嵌套类型中具有OR条件。
在同一查询下代表两个嵌套的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"
}
}]
}
}]
}
}]
}
}
}
query1和query2在性能上是否会因为我们多次嵌套blob而存在性能差异?
编辑1: 根据以下评论(@kamal),我在这里简化我的问题。
如果在“属于同一嵌套类型的属性,仅声明一次嵌套类型”与“属于同一嵌套类型的属性,两次声明嵌套类型,一次”之间进行布尔运算,则性能上会有任何差异每个属性”。
如下所示:
1。
nested :
or :
attribute1
attribute2
vs
2。
or :
nested :
attribute1
nested :
attribute2