JAVA API Runtime mappings bug?

I'm trying to set runtime mappings using the java api.

My setup is something like:

      new SearchRequest.Builder()
        .runtimeMappings("abc", java.util.Arrays.asList(
          new RuntimeField.Builder()
            .`type`(RuntimeFieldType.Keyword)
            .script(new Script.Builder()
              .inline(new InlineScript.Builder()
                .source(".... script source ...")
                .build()
              )
              .build()
            )
        ))
        .build()

Apologies for slight differences, if they come up, as I'm coding in scala, not java.

Anyway, the request fails. Looking at the REST json it looks like:

{
  "runtime_mappings": {
    "abc": [
      {
        "script": {
          "source": "... script source ..."
        },
        "type": "keyword"
      }
    ]
  }
}

Copying the json into postman, it fails there too.
But when I take out the array around the script, resulting in

{
  "runtime_mappings": {
    "abc": {
      "script": {
        "source": "... script source ..."
      },
      "type": "keyword"
    }
  }
}

it now works just fine in postman.

Am I doing something wrong in my Java API setup? Or is this a bug in the java API?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.