Skip to content

Count returns 0 and does not check for failed shards #1302

Open
@yogevyuval

Description

@yogevyuval

When performing count with an illegal query (too many clauses, invalid regex, etc'), the error is hidden from the user and the return value is 0, which is wrong.

For example if we run an invalid query, with date range filtering on several indices, the result will include "successful" shards which are considered successful because the query didn't event ran on them because they not meet the date range criteria, and some failed shards for indices who did meet the range, but failed because of the query.

The response is not validated and there is no check for failed shards. Actually there is a 6-years old TODO that mentions that:

image

Here is an example response:

{'count': 0,
 '_shards': {'total': 12,
  'successful': 6,
  'skipped': 0,
  'failed': 6,
  'failures': [{'shard': 0,
    'index': 'my-index-2020-01-20',
    'node': 'fHCBfQdfaraIDaqOH-i2Ug',
    'reason': {'type': 'query_shard_exception',

and the return value will be 0.

This behaviour is confusing and unwanted, as you can search for important events and get '0' from the count, although there was just an error in the query.

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