Skip to content

Redundant collapse in FieldCollapse type #2489

Open
@buinauskas

Description

@buinauskas

🐛 Wrong type

FieldCollapse has second-level collapse defined at the root level, which is not valid

According to spec, such query should work but it won't:

{
    "collapse": {
        "field": "country_id",
        "collapse": {
            "field": "category_id"
        }
    }
}

Results in the following response from /_search api:

{
    "error": {
        "root_cause": [
            {
                "type": "x_content_parse_exception",
                "reason": "[4:9] [collapse] unknown field [collapse]"
            }
        ],
        "type": "x_content_parse_exception",
        "reason": "[4:9] [collapse] unknown field [collapse]"
    },
    "status": 400
}

The second level collapse can be defined inside inner hits only with the field property but not at the FieldCollapse object itself.

Definition

I believe this could be enough

export class FieldCollapse {
  /**
   * The field to collapse the result set on
   */
  field: Field
  /**
   * The number of inner hits and their sort order
   */
  inner_hits?: InnerHits | InnerHits[]
  /**
   * The number of concurrent requests allowed to retrieve the inner_hits per group
   */
  max_concurrent_group_searches?: integer
-  collapse?: FieldCollapse
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions