question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

helpers.scan: TypeError: search() got an unexpected keyword argument 'doc_type'

See original GitHub issue

I’m using helpers.scan function to retrieve data. I passed in doc_type = log to it (following the online resource here). But I got this error:

<ipython-input-53-dffeaecb48f3> in export(self, outputFiles, host, indexDbName, docType, queryString, queryJson, size, fields, delimiter)
     41             w.writeheader()
     42             try:
---> 43                 for row in scanResponse:
     44                     for key,value in row['_source'].iteritems():
     45                         row['_source'][key] = unicode(value)

C:\ProgramData\Anaconda3\lib\site-packages\elasticsearch\helpers\actions.py in scan(client, query, scroll, raise_on_error, preserve_order, size, request_timeout, clear_scroll, scroll_kwargs, **kwargs)
    431     # initial search
    432     resp = client.search(
--> 433         body=query, scroll=scroll, size=size, request_timeout=request_timeout, **kwargs
    434     )
    435     scroll_id = resp.get("_scroll_id")
C:\ProgramData\Anaconda3\lib\site-packages\elasticsearch\client\utils.py in _wrapped(*args, **kwargs)
     82                 if p in kwargs:
     83                     params[p] = kwargs.pop(p)
---> 84             return func(*args, params=params, **kwargs)
     85 
     86         return _wrapped

TypeError: search() got an unexpected keyword argument 'doc_type'

I use ‘log’ as the doctype and I’m using elasticsearch server 6.3.0 Did I set the doctype wrong? Thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
fxdgearcommented, May 28, 2019

If you’re using the 7.x version of this library with a cluster of elasticsearch pre 7 you will be having problems because the removal of doc_type from ES. I’ve cleaned up the code and pushed a 7.0.1 version of the client a little bit ago which should be working with all functionalities of Elasticsearch.

If you want to use the scan helper on ES 7 it does work, using the data created in the examples directory of this repo we can run a scan like so:

 from elasticsearch.helpers import scan

 results = scan(
        client,
        query={
            "query": {
                "bool": {
                    "must": {"match": {"description": "fix"}},
                    "must_not": {"term": {"files": "test_elasticsearch"}},
                }
            }
        },
        index="git",
    )
    for result in results:
    print_hit(result)

If you want to use the 7.x version of this library you must upgrade your cluster to 7.x If you can’t yet upgrade your cluster to 7.x, then please for now, keep using the 6.x version of this library.

3reactions
CrimsonGlorycommented, Apr 16, 2019

got the same problem after the update from elasticsearch==6.3.1 to elasticsearch==7.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: search() got an unexpected keyword argument ...
I receive the error TypeError: search() got an unexpected keyword argument 'doc_type' . I went through a couple of links given below to...
Read more >
Python elasticsearch client : TypeError: index() got an ...
... (Python Elasticsearch Client — Python Elasticsearch client 8.3.1 documentation) I'm getting got an unexpected keyword argument error on:
Read more >
Helpers — Python Elasticsearch client 8.2.2 documentation
All bulk helpers accept an instance of Elasticsearch class and an iterable ... Any additional keyword arguments will be passed to the initial...
Read more >
Elasticsearch DSL Documentation - Read the Docs
Elasticsearch DSL is a high-level library whose aim is to help with writing and running queries against Elasticsearch.
Read more >
Changelog — Python 3.11.1 documentation
Python next: Release date: XXXX-XX-XX Core and Builtins: gh-100050: Honor existing errors obtained when searching for mismatching parentheses in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found