# JAVA API Runtime mappings bug?

**URL:** <https://discuss.elastic.co/t/java-api-runtime-mappings-bug/309588>\
**Category:** Elasticsearch\
**Tags:** runtime-fields\
**Created:** [July 14, 2022, 12:29am UTC](https://discuss.elastic.co/t/java-api-runtime-mappings-bug/309588 "2022-07-14T00:29:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicole.oresme](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nicole.oresme/32/108046_2.png) [@nicole.oresme](https://discuss.elastic.co/u/nicole.oresme)\
**Post date:** [July 14, 2022, 12:29am UTC](https://discuss.elastic.co/t/java-api-runtime-mappings-bug/309588/1 "2022-07-14T00:29:48Z")

</div>

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

My setup is something like:

```auto
      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:

```auto
{
  "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

```auto
{
  "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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 11, 2022, 12:30am UTC](https://discuss.elastic.co/t/java-api-runtime-mappings-bug/309588/2 "2022-08-11T00:30:33Z")

</div>

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