spring-projects / spring-projects/spring-ai

Error using ElasticSearch with filter expression

Open
#3,222 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

elastic search
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 10h
Merged PRs (30d)
5

Description

源代码:

 List<String> documentIds = (List<String>) requestBody.getOrDefault("documentIds", new ArrayList<>());
 Filter.Expression filterExpression = null;
filterExpression = b.in("id", documentIds).build();

经过debug调试后,发现elastic的报错信息是:
ErrorCause@163 "ErrorCause: {"phase":"dfs","failed_shards":[{"shard":0,"index":"my-index","node":"5gGemd0KQeafjhS6eo5CZw","reason":{"type":"query_shard_exception","reason":"Failed to parse query [(metadata.id:[15, 25])]","index_uuid":"70QktWW0T7OhYORdpL1Lsg","index":"my-index","caused_by":{"type":"parse_exception","reason":"Cannot parse '(metadata.id:[15, 25])': Encountered " <RANGE_GOOP> "25 "" at line 1, column 18.\r\nWas expecting:\r\n "TO" ...\r\n ","caused_by":{"type":"parse_exception","reason":"Encountered " <RANGE_GOOP> "25 "" at line 1, column 18.\r\nWas expecting:\r\n "TO" ...\r\n "}}}}],"grouped":true,"type":"search_phase_execution_exception","reason":"all shards failed","root_cause":[{"index_uuid":"70QktWW0T7OhYORdpL1Lsg","index":"my-index","type":"query_shard_exception","reason":"Failed to parse query [(metadata.id:[15, 25])]"}]}"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the requestBody filter construction shown in the issue and reproduce the query against Elasticsearch using the reported documentIds values. Trace how b.in("id", documentIds).build() becomes the metadata.id query, then verify that the resulting filter executes without the reported query parse exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
elasticsearch, java
Domain
backend, search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.