Skip to content

[BUG] Search fails when from parameter is negative #11290

@soosinha

Description

@soosinha

Describe the bug
When the from parameter in the search query is negative, the search fails with search_phase_execution_exception (HTTP status 500)

To Reproduce
Steps to reproduce the behavior:

  1. Create an index my-index
  2. Add few documents
POST "_bulk?pretty" -H 'Content-Type: application/json' -d'
{ "index": { "_index": "my-index", "_id": "1" } }
{ "description": "ice cream" }
{ "index": { "_index": "my-index", "_id": "2" } }
{ "description": "croissant" }
{ "index": { "_index": "my-index", "_id": "3" } }
{ "description": "tennis shoe" }
{ "index": { "_index": "my-index", "_id": "4" } }
{ "description": "hightop" }
'
  1. Perform search
POST "my-index/_search?pretty" -H 'Content-Type: application/json' -d '{"size":10,"from":-5}'
  1. See error
{
  "error" : {
    "root_cause" : [ ],
    "type" : "search_phase_execution_exception",
    "reason" : "",
    "phase" : "fetch",
    "grouped" : true,
    "failed_shards" : [ ],
    "caused_by" : {
      "type" : "null_pointer_exception",
      "reason" : "Cannot read field \"shardIndex\" because \"shardDoc\" is null"
    }
  },
  "status" : 500
}

Expected behavior
Search should fail with illegal_argument_exception (HTTP status 400)

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    SearchSearch query, autocomplete ...etcbugSomething isn't working

    Type

    No type

    Projects

    Status

    Later (6 months plus)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions