opensearch-project / opensearch-project/opensearch-java
[BUG] OpenSearchException: Request failed: [mapper_parsing_exception] failed to parse
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 165
- Forks
- 250
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 26
Description
What is the bug?
When we push the document as a JSON string using IndexRequest, the API fails with the below error the same works if we pass the document as a java map.
Caused by: org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [mapper_parsing_exception] failed to parse
at org.opensearch.client.transport.aws.AwsSdk2Transport.parseResponse(AwsSdk2Transport.java:530)
at org.opensearch.client.transport.aws.AwsSdk2Transport.executeSync(AwsSdk2Transport.java:438)
at org.opensearch.client.transport.aws.AwsSdk2Transport.performRequest(AwsSdk2Transport.java:241)
at org.opensearch.client.opensearch.OpenSearchClient.index(OpenSearchClient.java:764)
Are there any working examples where JSON string is pushed as a document instead of java POJOs?
I'm trying this in Scala.
val openSearchClient: OpenSearchClient = new OpenSearchClient(
new AwsSdk2Transport(httpClient,
host,
"aoss",
region,
AwsSdk2TransportOptions.builder().setCredentials(credentials).build()))
val documentJsonStr = "{'name': 'yashwanth', 'age': '23'}"
val documentJson = JsonData.of[String](documentJsonStr)
val request = IndexRequest.of[JsonData](f => f.index(index).document(documentJson))
openSearchClient.index(request)
Below code works, where the document is passed as java map to the same index
val openSearchClient: OpenSearchClient = new OpenSearchClient(
new AwsSdk2Transport(httpClient,
host,
"aoss",
region,
AwsSdk2TransportOptions.builder().setCredentials(credentials).build()))
val temp2 = new util.HashMap[String, String]()
temp2.put("name", "yashwanth")
temp2.put("age", "23")
val documentIndexRequest =
new IndexRequest.Builder().id("1").index(index).document(temp2).build
openSearchClient.index(documentIndexRequest)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the IndexRequest.document call and inspect JsonData.of[String], then trace the request through OpenSearchClient.index and AwsSdk2Transport. Reproduce the Scala JSON-string example alongside the working HashMap example; done should identify why the document forms differ and provide a verified usage path or a clearly scoped client fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, scala
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100