Skip to content

[ENHANCEMENT] Convert dedup pushdown to composite + top_hits #4797

Closed

Description

@LantaoJin

Is your feature request related to a problem?
#3972 converts dedup command to collapse search when pushdown enabled. By benchmarking, the performance of collapse search shows worse than composite + top_hits or terms + top_hits. Here is the benchmarking result:

  1. terms + top_hits 2000ms
  2. composite + top_hits (missing_bucket false/true:) 3500ms/4500ms
  3. collapse 13000ms

Additional, (1) and (2) can support dedup on bool, date etc fields and script expr, (3) only works on keyword/numeric field. and (2) can support search_after in future

What solution would you like?
Refactor to approach (2)

Do you have any additional context?

curl -XPOST "http://localhost:9200/big5/_search" -H 'Content-Type: application/json' -d'
{
  "size": 0,
  "_source": false,
  "aggs": {
    "packets": {
      "terms": {
        "field": "cloud.region",
        "size": 10000
      },
      "aggs": {
        "topN": {
          "top_hits": {
            "size": 1,
            "_source": true
          }
        }
      }
    }
  }
}'

2000ms

curl -XPOST "http://localhost:9200/big5/_search" -H 'Content-Type: application/json' -d'
{
  "size": 0,
  "timeout": "1m",
  "_source": false,
  "aggs": {
    "packets": {
      "composite": {
        "size": 10000,
        "sources": [
          {
            "name": {
              "terms": {
                "field": "cloud.region",
                "missing_bucket": true
              }
            }
          }
        ]
      },
      "aggs": {
        "topN": {
          "top_hits": {
            "size": 1,
            "_source": true
          }
        }
      }
    }
  }
}'

missing_bucket false 3500ms
missing_bucket true 4500ms

curl -XPOST "http://localhost:9200/big5/_search" -H 'Content-Type: application/json' -d'
{
  "from": 0,
  "size": 10000,
  "timeout": "1m",
  "_source": true,
  "collapse": {
    "field": "cloud.region"
  }
}'

13000ms

Activity

  1. added
    enhancement
    on Nov 13, 2025
  2. changed the title [-][ENHANCEMENT] Re[/-] [+][ENHANCEMENT] Convert dedup pushdown to `composite + top_hits`[/+] on Nov 13, 2025
  3. self-assigned this
    on Nov 13, 2025
  4. added
    PPL
    pushdown
    and removed on Nov 13, 2025
  5. anasalkouz commented on Nov 17, 2025

    @anasalkouz
    Member

    @LantaoJin can we target 3.4 for this?

  6. moved this from Not Started to Done in PPL Trackeron Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

PPLenhancementpushdown

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions