添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
高兴的鸭蛋  ·  “竞”动山野 ...·  5 月前    · 
好帅的草稿本  ·  Amazon.com·  1 年前    · 
强健的碗  ·  surface pro 3 ...·  1 年前    · 
成熟的圣诞树  ·  坚守兰大60年 ...·  1 年前    · 

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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)
     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!

Thanks for the issue. I'll look into it.

FYI while using elasticsearch-py you should be matching major versions. I can't make any guarantee that using es-py==7 will work with older version of Elasticsearch.

There is a package released now you can install elasticsearch6 for a package that's designed to work with Elasticsearch 6.x.

https://github.com/elastic/elasticsearch-py#compatibility

Thanks for the reply
So you mean it may be the version issue but not the code
but is it still matter when I call the elasticsearch host rather than the localhost
Thanks a lot

@qilds123 well it IS the code, but starting in ES 7 doc_types are being phased out. The doc type _doc is default, and is used in all urls communicating with an ES 7 cluster. In ES8 the _doc doc_type is going away completely.

When I released v7 of this project, I change requirement of using doc_type as a required positional argument in each method to being an optional kwarg with a default of _doc. But turns out I removed it from search() but I had a gap in my testing :( SO it didn't get spotted before releasing 7.0.0.

@fxdgear Hey, I am on version 7.0.1, but the error is still there for me. What can I do?

>>> es.search(index='my_index', doc_type='my_index',
... body={'query': {'match': {'text': 'this test'}}})
Traceback (most recent call last):
  File "<console>", line 2, in <module>
  File "/home/haider/Desktop/online courses/microblog/venv/lib/python3.7/site-packages/elasticsearch/client/utils.py", line 84, in _wrapped
    return func(*args, params=params, **kwargs)
TypeError: search() got an unexpected keyword argument 'doc_type'
>>> es.search(index='my_index', doc_type='my_index', body={'query': {'match': {'text': 'this test'}}})
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/haider/Desktop/online courses/microblog/venv/lib/python3.7/site-packages/elasticsearch/client/utils.py", line 84, in _wrapped
    return func(*args, params=params, **kwargs)
TypeError: search() got an unexpected keyword argument 'doc_type'

And this is how I set the index:

>>> es.index(index='my_index', doc_type='my_index', id=1, body={'text': 'this is a test'})
{'_index': 'my_index', '_type': 'my_index', '_id': '1', '_version': 1, 'result': 'created', '_shards': {'total': 2, 'successful': 1, 'failed': 0}, '_seq_no': 0, '_primary_term': 1}
>>> es.index(index='my_index', doc_type='my_index', id=2, body={'text': 'a second test'})
{'_index': 'my_index', '_type': 'my_index', '_id': '2', '_version': 1, 'result': 'created', '_shards': {'total': 2, 'successful': 1, 'failed': 0}, '_seq_no': 1, '_primary_term': 1}