# Cannot call apoc.es.put to elastic search 8.6

**URL:** <https://community.neo4j.com/t/cannot-call-apoc-es-put-to-elastic-search-8-6/61757>\
**Category:** Procedures & APOC\
**Tags:** apoc, elasticsearch\
**Created:** [March 30, 2023, 10:37am UTC](https://community.neo4j.com/t/cannot-call-apoc-es-put-to-elastic-search-8-6/61757 "2023-03-30T10:37:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![azhar](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/azhar/32/19316_2.png) [@azhar](https://community.neo4j.com/u/azhar)\
**Post date:** [March 30, 2023, 10:37am UTC](https://community.neo4j.com/t/cannot-call-apoc-es-put-to-elastic-search-8-6/61757/1 "2023-03-30T10:37:11Z")

</div>

I updated to elastic 8.6 from elastic 7.17. I am using neo4j 4.4. Before this I run

CALL apoc.es.put("es-container","might\_index","docs", "datatest1", null, {  
id: "John Doe"  
});

it works fine. Now after upgrading to elastic 8.6, I get the error below:

Failed to invoke procedure `apoc.es.put`: Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: [http://es-container:9200/might\_index/docs/datatest1](http://es-container:9200/might_index/docs/datatest1)

How to fix this?

---

<div class="post-metadata">

**Author:** ![azhar](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/azhar/32/19316_2.png) [@azhar](https://community.neo4j.com/u/azhar)\
**Post date:** [March 31, 2023, 2:38am UTC](https://community.neo4j.com/t/cannot-call-apoc-es-put-to-elastic-search-8-6/61757/3 "2023-03-31T02:38:25Z")

</div>

I found out that to send to elastic search 8.6, we need to put header

```auto
Accept: "application/vnd.elasticsearch+json;compatible-with=7"
Content-Type: "application/vnd.elasticsearch+json;compatible-with=7"

```

In order to do that, I need to recompile the apoc.es source. It involves two files:

1. ElasticSearch.java
2. LoadJson.java

To compile, follow [https://community.neo4j.com/t/neo-clienterror-procedure-procedurecallfailed-caused-by-java-lang-nosuchmethoderror-org-roaringbitmap-container-org-roaringbitmap-arraycontainer-add-char/47477?u=pinox101](https://community.neo4j.com/t/neo-clienterror-procedure-procedurecallfailed-caused-by-java-lang-nosuchmethoderror-org-roaringbitmap-container-org-roaringbitmap-arraycontainer-add-char/47477)

**Changes in ElasticSearch.java**

```auto
   private String contentType(Object payload) {
    	// commented by Azhar 31 March 2023 to support Elastic 8.6.2
        //return "application/json";
    	return "application/vnd.elasticsearch+json;compatible-with=7";
    }

```

**Changes in LoadJson.java**

```auto
  public static Stream<MapResult> loadJsonStream(@Name("urlOrKeyOrBinary") Object urlOrKeyOrBinary, @Name("headers") Map<String, Object> headers, @Name("payload") String payload, String path, boolean failOnError, String compressionAlgo, List<String> pathOptions) {
        if (urlOrKeyOrBinary instanceof String) {
            headers = null != headers ? headers : new HashMap<>();
            headers.putAll(Util.extractCredentialsIfNeeded((String) urlOrKeyOrBinary, failOnError));
        }
        headers.put("Accept","application/vnd.elasticsearch+json;compatible-with=7");
        // Azhar wants to see if the headers was ok
        //System.out.println("headers: " + headers.toString());

```

I am sorry that the system does not allow me to upload java or jar files. Thank you
