danielberkompas/elasticsearch-elixir

Document mapping type name can't start with '_'

jhonathas opened this issue · 3 comments

When using put_document I received the following error:

** (MatchError) no match of right hand side value: {:error, %Elasticsearch.Exception{col: nil, line: nil, message: "Document mapping type name can't start with '_', found: [_doc]", query: nil, raw: %{"error" => %{"reason" => "Document mapping type name can't start with '_', found: [_doc]", "root_cause" => [%{"reason" => "Document mapping type name can't start with '_', found: [_doc]", "type" => "invalid_type_name_exception"}], "type" => "invalid_type_name_exception"}, "status" => 400}, status: 400, type: "invalid_type_name_exception"}}

My Elasticsearch version is 6.5.2.

I checked that by default document_url is using "_doc" and it seems that it will no longer be possible to start with "_" the type. Is there a way to solve without changing the code?

https://github.com/infinitered/elasticsearch-elixir/blob/5c7c2dd186217cb7d3c6252275e4ae47b193fe4b/lib/elasticsearch.ex#L127

@jhonathas Since Elasticsearch is removing mapping types in favor of _doc, this should be working in 6.5.2. Elasticsearch merged a PR to support _doc over a year ago.

We're running tests here against 6.4.0, and the tests exercise put_document quite heavily. Everything seems to be working?

Can you share more details about how you're calling put_document? Also, double check to make sure you're not running an older version of Elasticsearch.

I just realized that even giving the command to install version 6.5.2 (mix elasticsearch.install vendor --version 6.5.2), he installed 5.1.1.

I'm testing other versions. That may have been it.

Now I ran the command again to install version 6.5.2 and it installed 6.5.1. I think the problem was really in the version. Now everything is working.

{ "name" : "k417ww3", "cluster_name" : "elasticsearch", "cluster_uuid" : "tnTNRrwKQnOiN57O40VK9Q", "version" : { "number" : "6.5.1", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "8c58350", "build_date" : "2018-11-16T02:22:42.182257Z", "build_snapshot" : false, "lucene_version" : "7.5.0", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" }

Thank you very much.

There is something strange in the install command, but now it worked.