What diffirent about nested and bool composite query

I have devloped a component that translate expression to esdel, now i have an exp like that
"((extras.key== ‘k1’ and extras.value==100 ) or (extras.key== “k2” and extras.value==”v2”))", in that, ”extras“ is a nested field
we have tow strategies to do that:

  1. the whole is bool query,
    bool(or)
    -- nested bool(and)
    -- nested bool(and)
  2. the whole is nested query
    nested
    • bool (or)
      -- bool (and)
      -- bool (and)
{
  "query": {
    "bool": {
      "should": [
        {
			"nested": {
			  "path": "extras",
			  "query": {
				"bool": {
				  "must": [
					{
					  "term": {
						"extras.key": "k1"
					  }
					},
					{
					  "term": {
						"extras.value": 100
					  }
					}
				  ]
				}
			  }
			}
		},
		{
			"nested": {
			  "path": "extras",
			  "query": {
				"bool": {
				  "must": [
					{
					  "term": {
						"extras.key": "k2"
					  }
					},
					{
					  "term": {
						"extras.value": "v2"
					  }
					}
				  ]
				}
			  }
			}
		}
      ]
    }
  }
}
{
  "query": {
          "nested": {
            "path": "extras",
            "query": {
              "bool": {
                "should": [
                  {
                    "bool": {
                      "must": [
                        {
                          "term": {
                            "extras.key": "k1"
                          }
                        },
                        {
                          "term": {
                            "extras.value": 100
                          }
                        }
                      ]
                    }
                  },
                  {
                    "bool": {
                      "must": [
                        {
                          "term": {
                            "extras.key": "k2"
                          }
                        },
                        {
                          "term": {
                            "extras.value": "v2"
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }
          }
  }
}

i have run them in head , the same returned
what is the diffirent about the tow in performance or they are the same one?

Please don't post images of text as they are hard to read, may not display correctly for everyone, and are not searchable.

Instead, paste the text and format it with </> icon or pairs of triple backticks (```), and check the preview window to make sure it's properly formatted before posting it. This makes it more likely that your question will receive a useful answer.

It would be great if you could update your post to solve this.

I have some idea and solved,and post the solution,but it is wrote by chinese,

https://www.toutiao.com/article/7223768235760812583/

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.