Giotto
Giotto

Reputation: 29

elastic: Error 500 (Internal Server Error): all shards failed [type=search_phase_execution_exception] when searching frequently through golang

I'm using golang to write a tool which can search the relating information about a list of userIds respectively. The program stopped with "elastic: Error 500 (Internal Server Error): all shards failed [type=search_phase_execution_exception] " for every 500 times of searching. I can continue the next 500 times searchs in about 5 minutes later. I wonder why this happens.

Upvotes: 1

Views: 2312

Answers (1)

ARKhan
ARKhan

Reputation: 2015

In my case, the error was because in my ES query, I was using aggregation on _id field of the ES Document. If you don't set this field, it will automatically be set by ES itself. In anyway, you will end up getting this transient error.

elastic: Error 500 (Internal Server Error): all shards failed [type=search_phase_execution_exception]

It was working fine till the application usage grows and the document count increases to 0.2 Million.

Solution: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-id-field.html

The _id field is restricted from use in aggregations, sorting, and scripting. In case sorting or aggregating on the _id field is required, it is advised to duplicate the content of the _id field into another field that has doc_values enabled.

PS: I was using ES version 8.x.x.

Upvotes: 0

Related Questions