Skip to content

Conversation

@iverase
Copy link
Contributor

@iverase iverase commented May 23, 2025

The exceptions happens when user provides unsupported doc value types (either the type is wrong or it is multi-valued) so the rest status code should be 400 instead of 500.

Current error:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_state_exception",
        "reason": "failed to extract doc:0, the grouping field must be single valued"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "test",
        "node": "6lqb2ehXRrOdVMeXe_7PHg",
        "reason": {
          "type": "illegal_state_exception",
          "reason": "failed to extract doc:0, the grouping field must be single valued"
        }
      }
    ],
    "caused_by": {
      "type": "illegal_state_exception",
      "reason": "failed to extract doc:0, the grouping field must be single valued",
      "caused_by": {
        "type": "illegal_state_exception",
        "reason": "failed to extract doc:0, the grouping field must be single valued"
      }
    }
  },
  "status": 500
}

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@elasticsearchmachine elasticsearchmachine added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label May 23, 2025
Copy link
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@javanna
Copy link
Member

javanna commented May 23, 2025

Thanks for fixing this, did you see this in practice? I wonder how users are going to experience this error. Is there anything else we can do to fail earlier?

@iverase
Copy link
Contributor Author

iverase commented May 23, 2025

Is there anything else we can do to fail earlier?

I wondered the same. The issue here is for multi-value fields as the only way to check for it is looking into the actua data. I am not sure if we can check before it happens.

@javanna
Copy link
Member

javanna commented May 23, 2025

Agreed @iverase we don't make distinctions around number of values in Elasticsearch, sounds like there isn't much we can do about this other than changing the status code. The error is pretty clear though, it should be easy to understand. Maybe the id of the doc is confusing, but we don't have the _id available when the error is thrown.

@iverase iverase added the auto-backport Automatically create backport pull requests when merged label May 23, 2025
@iverase iverase merged commit 8085eea into elastic:main May 23, 2025
18 checks passed
@iverase iverase deleted the collapseException branch May 23, 2025 08:45
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 128348

iverase added a commit to iverase/elasticsearch that referenced this pull request May 23, 2025
…ector (elastic#128348)

# Conflicts:
#	server/src/main/java/org/elasticsearch/lucene/grouping/GroupingDocValuesSelector.java
elasticsearchmachine pushed a commit that referenced this pull request May 23, 2025
…ector (#128348) (#128355)

# Conflicts:
#	server/src/main/java/org/elasticsearch/lucene/grouping/GroupingDocValuesSelector.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >non-issue :Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants