0

I'm using elasticSearch with RestHighLevelClient and Java. When I put query: QueryBuilder qb = new QueryStringQueryBuilder("" + valueSearch.toLowerCase() + ""). Where valueSearch contain "/" -> example REC2/. The searchResponse = client.search(searchRequest, RequestOptions.DEFAULT) return me Caused by: org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]. However, when I send Rec2/2/3 or Rec// everything its ok.

Version elastic: 7.3.0

3
  • Can you share the ES server logs, the detailed error must be there. Commented Oct 13, 2022 at 9:46
  • Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed] Commented Oct 13, 2022 at 9:49
  • and now I found: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"Failed to parse query [list/]","index_uuid":" Commented Oct 13, 2022 at 9:50

1 Answer 1

1

The query_string query has some reserved characters that you're now allowed to use in queries (such as /), except if properly escaped.

So you should escape all reserved characters that are present in valueSearch.toLowerCase()

Sign up to request clarification or add additional context in comments.

Comments