相关文章推荐
慷慨大方的胡萝卜  ·  1-PyCharm ...·  昨天    · 
重情义的数据线  ·  Conda 创建 Python ...·  昨天    · 
暴走的电池  ·  python ...·  昨天    · 
刚毅的长颈鹿  ·  Windows10 ...·  12 小时前    · 
读研的豆芽  ·  JavaScript 调试功能 - ...·  1 月前    · 
考研的大脸猫  ·  array boundary ...·  1 年前    · 
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

TypeError: search() got an unexpected keyword argument 'doc_type' for elastic search version 5.6

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 .