Home > Net >  Elasticsearch 7.5.2, paginating, getting "Rejecting mapping update as the final mapping would h
Elasticsearch 7.5.2, paginating, getting "Rejecting mapping update as the final mapping would h

Time:08-26

Elaticsearch 7.5.2, I'm trying to paginate over a query. The first POST goes fine, and returns me a scroll_id. Then I loop for next page like this:

POST /my_index/_search/scroll
{
  "scroll": "1m",
  "scroll_id":"DnF1ZXJ5VGhlbkZldGNoaQAAAAAGt4QrFlNTRFVveG80UlhTQ1M1RmVDS2x4Y1EAAAAABreELBZTU0RVb3hvNFJYU0NTNUZlQ0tseGNRAAAAAAWsCoQWY1BrWUZhOVhRNlNBeEkwMkgyeFZtdwAAAAAFrAqFFmNQa1lGYTlYUTZTQXhJMDJIMnhWbXcAAAAABawKhhZjUGtZRmE5WFE2U0F4STAySDJ4Vm[...]"
}

(Note that the scroll_id is quite long, that's why I need to use a POST instead of a GET) At that point I get a 400 error with this message:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Rejecting mapping update to [my_index] as the final mapping would have more than 1 type: [_doc, _search]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Rejecting mapping update to [my_index] as the final mapping would have more than 1 type: [_doc, _search]"
  },
  "status": 400
}

As if it were trying to index a document, instead of paginating a query.

Any idea...? Thanks.

CodePudding user response:

According to the official documentation, this is because you need to remove the index name from the second call. Do it like this:

remove the index name
     |
     v
POST /_search/scroll
{
  "scroll": "1m",
  "scroll_id":"DnF1ZXJ5VGhlbkZldGNoaQAAAAAGt4QrFlNTRFVveG80UlhTQ1M1RmVDS2x4Y1EAAAAABreELBZTU0RVb3hvNFJYU0NTNUZlQ0tseGNRAAAAAAWsCoQWY1BrWUZhOVhRNlNBeEkwMkgyeFZtdwAAAAAFrAqFFmNQa1lGYTlYUTZTQXhJMDJIMnhWbXcAAAAABawKhhZjUGtZRmE5WFE2U0F4STAySDJ4Vm[...]"
}
  • Related