Elasticsearch-py: Why is doc_type still required?

Created on 19 Sep 2018  路  3Comments  路  Source: elastic/elasticsearch-py

When indexing a document with es.index, why is it still required to use the doc_type parameter? I get an error if I don't include it. I.e. res = es.index(index=company_A, doc_type="_doc", body=doc) vs res = es.index(index=company_db, body=doc)

Most helpful comment

@seanziee There's a long and a short answer. As @YuvalPruss mentioned it's been "removed" Though it's only been "soft removed" that meaning doc_type still exists, but it's defaulted to _doc. As @nguyenvulong mentioned they will be completely removed in 8.

As for the python client, this leaves us with a tricky situation.

a person running a single cluster running 7.x doesn't need the doc_type.
but
A person running multiple clusters and doing cross cluster search the doc_type is still needed.

The Latest update I've pushed into master (but haven't issued a release yet on pypi cause 7 is still only an RC at this time) has taken the approach to default the value of doc_type in the method signature so that it becomes optional to use in your python apps.

All 3 comments

Great question, since the elasticsearch had removed the mapping types:

Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Mapping types will be completely removed in Elasticsearch 7.0.0.

https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html

@YuvalPruss you may want to fix the "embedded URL" in your post, as it redirects to "https://github.com/elastic/elasticsearch-py/issues/url" instead of "elastic.co" when someone clicks it

Also there're some updates as follows:

Types will be deprecated in APIs in Elasticsearch 7.0.0, and completely removed in 8.0.0.

@seanziee There's a long and a short answer. As @YuvalPruss mentioned it's been "removed" Though it's only been "soft removed" that meaning doc_type still exists, but it's defaulted to _doc. As @nguyenvulong mentioned they will be completely removed in 8.

As for the python client, this leaves us with a tricky situation.

a person running a single cluster running 7.x doesn't need the doc_type.
but
A person running multiple clusters and doing cross cluster search the doc_type is still needed.

The Latest update I've pushed into master (but haven't issued a release yet on pypi cause 7 is still only an RC at this time) has taken the approach to default the value of doc_type in the method signature so that it becomes optional to use in your python apps.

Was this page helpful?
0 / 5 - 0 ratings