Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] terminate_after Parameter Impact on Dropdown List Query Results #11753

Open
kaituo opened this issue Jan 4, 2024 · 2 comments
Open

[BUG] terminate_after Parameter Impact on Dropdown List Query Results #11753

kaituo opened this issue Jan 4, 2024 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed Search:Aggregations

Comments

@kaituo
Copy link

kaituo commented Jan 4, 2024

Describe the bug

I'm reaching out to report an inconsistency we've observed with the terminate_after parameter in our search queries, which seems to be affecting the functionality of dropdown lists in the frontend.

Issue Description:

The frontend utilizes a query that leverages the terminate_after parameter to calculate dropdown lists. This has been working as expected up to version 2.9. However, upon upgrading to version 2.11, the same query now returns empty results.

Query Example:

GET sensorsdata-*/_search
{
  "timeout": "1000ms",
  "terminate_after": 100000,
  "size": 0,
  "aggs": {
    "termsAgg": {
      "terms": {
        "order": { "_count": "desc" },
        "size": 500,
        "field": "Host.keyword"
      }
    }
  },
  "stored_fields": ["*"],
  "script_fields": {},
  "docvalue_fields": [{
    "field": "TimeStamp",
    "format": "date_time"
  }],
  "_source": { "excludes": [] },
  "query": { "bool": { "must": [], "filter": [], "should": [], "must_not": [] } }
}

Observations:

  • Setting terminate_after to 0 or increasing the value to 500,000 results in the expected output.
  • The default value of 100,000 for terminate_after has been a constant for over 4 years, as per our historical code reference here.

Potential Explanations:

  • The index might contain more than 100,000 documents, but fewer than 500,000. Since terms aggregation requires scanning all documents, partial results are not feasible.
  • Disabling terminate_after by setting it to 0 allows the query to scan all necessary documents to complete the aggregation.

Related Changes:

  • In the 2.11 update, we identified a change that might be correlated with this issue, detailed in this pull request.

We need assistance in pinpointing the root cause of this discrepancy. Could you please help us investigate this matter further? Any insights into changes between versions 2.9 and 2.11 that could affect the terminate_after behavior would be invaluable.

Related component

Search:Aggregations

To Reproduce

  1. Construct an index that contains a document count exceeding 100,000 yet remains below 500,000. Ensure each document includes the fields Host.keyword and TimeStamp.
  2. run the following query:
GET sensorsdata-*/_search
{
  "timeout": "1000ms",
  "terminate_after": 100000,
  "size": 0,
  "aggs": {
    "termsAgg": {
      "terms": {
        "order": { "_count": "desc" },
        "size": 500,
        "field": "Host.keyword"
      }
    }
  },
  "stored_fields": ["*"],
  "script_fields": {},
  "docvalue_fields": [{
    "field": "TimeStamp",
    "format": "date_time"
  }],
  "_source": { "excludes": [] },
  "query": { "bool": { "must": [], "filter": [], "should": [], "must_not": [] } }
}

Expected behavior

We expect to see non-empty terms aggregation result.

Additional Details

No response

@kaituo kaituo added bug Something isn't working untriaged labels Jan 4, 2024
@peternied peternied added help wanted Extra attention is needed and removed untriaged labels Jan 17, 2024
@peternied
Copy link
Member

[Triage - attendees 1 2 3 4]
Thanks for filing, please feel free to submit a pull request.

@peternied
Copy link
Member

@reta you mentioned there was a related issue that was resolved [1] could you take a look into this report?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed Search:Aggregations
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants