opensearch-project / opensearch-project/opensearch-java

[BUG] OpenSearchException: Request failed: [mapper_parsing_exception] failed to parse

Open
#362 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good first issue
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.