olivere / elastic

Deprecated: Use the official Elasticsearch client for Go at https://github.com/elastic/go-elasticsearch

Home Page:https://olivere.github.io/elastic/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is a correct update endpoint for communication between elastic.v7 client and Elasticsearch 6.x server?

jshenpdp opened this issue · comments

I am currently getting backwards incompatibility issue when hitting endpoint of /update using elastic.v7 as client to Elasticsearch 6.x server.
I noticed that for update, the 7.x endpoint is POST /<index>/_update/<_id>, while the 6.x is expecting POST /<index>/_doc/<_id>/_update.

This results in that when I make update operation from v7 client to 6.x Elasticsearch server, I am seeing the error below

{"error":{"root_cause":[{"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_update]"}],"type":"invalid_type_name_exception","reason":"Document mapping type name can't start with '_', found: [_update]"},"status":400}

I found this difference when I enabled client side tracelog.

Which version of Elastic are you using?

[x] elastic.v7 (for Elasticsearch 7.x, was actually using 6.x server though, as a way to test backwards compatibility)
[] elastic.v6 (for Elasticsearch 6.x)
[ ] elastic.v5 (for Elasticsearch 5.x)
[ ] elastic.v3 (for Elasticsearch 2.x)
[ ] elastic.v2 (for Elasticsearch 1.x)

Please describe the expected behavior

Successful update with POST /<index>/_update/<_id> from v7 client to both Elasticsearch 6.x and 7.x servers.

Please describe the actual behavior

Error described above with POST /<index>/_update/<_id> endpoint from v7 client to Elasticsearch 6.x server.

Any steps to reproduce the behavior?

  1. Spin up a ES 6 server
  2. Use elastic v7 as client
  3. Create an index
  4. Insert a document
  5. Update the document with POST /<index>/_update/<_id> endpoint from elastic.v7

Is this a suggestion of not to use v7 client for 6.x server? Originally I am thinking of sticking this plan as it would be easier to use one client to request to both Elasticsearch servers (v6 and v7).

For ES 6.x, you need to use Elastic v6. For ES 7.x, you need to use Elastic v7. See the README.

Notice that you should also move to the official client if you're already working on the update.