Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
I want to read the documents from a specific index and a specific type from elastic search. I construct the query:
es.search(index="document_index, doc_type="document_type", body={"query": {"match_all": {}}})['hits']['total']
I receive the error
TypeError: search() got an unexpected keyword argument 'doc_type'
. I went through a couple of links given below to look for a solution but everywhere the main answer is to downgrade the ES version. But our requirement is to keep ES version 5.6.
https://elasticsearch-py.readthedocs.io/en/master/
https://towardsdatascience.com/getting-started-with-elasticsearch-in-python-c3598e718380
https://marcobonzanini.com/2015/02/02/how-to-query-elasticsearch-with-python/
and a couple of more
Is there an alternative to mention the document type?
Seems your elasticsearch python client version is higher than
v5.6
. Remove the existing one with a
doc_type
compatible version e.g 5.5.3
Remove
:
pip uninstall elasticsearch
and then
Install
pip install elasticsearch==5.5.3
N.B
I'm suggesting to do that because elasticsearch doesn't support multiple doc types per index any more using
doc_type
There is no another type. It is giving error due to different version
Yesterday I faced the same problem You need to check the elasticsearch version or You can directly download the version by this command:
sudo pip install elasticsearch==version(e.g 6.3.1)
You can check current elastic version by this command - pip freeze
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.