Skip to content

SQL: consider adding support for same document fields comparison #34400

@astefan

Description

@astefan

The idea originally surfaced in this discuss thread. The solution fit for SQL would include the terms aggregation inside a composite one to allow for pagination:

GET flights/_search
{
  "size": 0,
  "_source": {
    "excludes": []
  },
  "aggs": {
    "whatever": {
      "composite": {
        "sources": [
          {
            "2": {
              "terms": {
                "script": {
                  "source": "if (doc['DestWeather.keyword'] == doc['OriginWeather.keyword']) return doc['DestWeather.keyword']; else return 'other';",
                  "lang": "painless"
                }
              }
            }
          }
        ]
      }
    }
  },
  "query": {
    "match_all": {}
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions