AND in SQL query is translated to nested bool

Hi,

When I translate the following to DSL I see multiple nested bool instead one bool that contains all the conditions. Can I control it?

GET _sql/translate
{
  "query": """
   SELECT * FROM "base" 
  WHERE "Id" = '6238caf' AND "stream" LIKE 'rrr' AND "source" = 'WW' AND "name" LIKE 'abc' AND "param1" LIKE 'ccc'
  """,
  "fetch_size": 10000
}

Provide:

"query" : {
    "bool" : {
      "must" : [
        {
          "bool" : {
            "must" : [
              {
                "bool" : {
                  "must" : [
                    {
                      "bool" : {
                        "must" : [
                          {
                            "term" : {
                              "Id" : {
                                "value" : "6238caf",
                                "boost" : 1.0
                              }
                            }
                          },
                          {
                            "term" : {
                              "streamName" : {
                                "value" : "rrr",
                                "boost" : 1.0
                              }
                            }
                          }
                        ],
                        "adjust_pure_negative" : true,
                        "boost" : 1.0
                      }
                    },
                    {
                      "term" : {
                        "source" : {
                          "value" : "WW",
                          "boost" : 1.0
                        }
                      }
                    }
                  ],
                  "adjust_pure_negative" : true,
                  "boost" : 1.0
                }
              },
              {
                "term" : {
                  "name" : {
                    "value" : "abc",
                    "boost" : 1.0
                  }
                }
              }
            ],
            "adjust_pure_negative" : true,
            "boost" : 1.0
          }
        },
        {
          "term" : {
            "param1" : {
              "value" : "ccc",
              "boost" : 1.0
            }
          }
        }
      ],
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  },

Expected:

"query": {
    "bool": {
        "must": [
            {"term": { "Id" :      "622e624f" }},
            {"term": { "streamName": "rrr"}},
            {"term": { "source": "WWW"}},
            {"term": { "name": "abc"}},
        ]
    }
  }

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