在pyelasticsearch中指定搜索类型

时间:2015-01-09 02:20:47

标签: search pyelasticsearch

使用pyelasticsearch时有没有办法指定搜索类型? “扫描”,“滚动”,“query_and_fetch”等文档中没有任何内容。运行以下代码:

from pyelasticsearch import ElasticSearch
es = ElasticSearch(...)

query = {
    "query" : {
        "term" : { "DocContent" : "the" }
    }
}
x = es.search(query, index='main', search_type='scan', scroll='1m')

产生以下错误:

E:\query>python query.py
Traceback (most recent call last):
  File "query.py", line 11, in <module>
    x = es.search(query, index='main', scroll='1m', document_type='scan')
  File "C:\Python27\lib\site-packages\pyelasticsearch-0.7.1-py2.7.egg\pyelasticsearch\client.py", line 96, in decorate
    return func(*args, query_params=query_params, **kwargs)
  File "C:\Python27\lib\site-packages\pyelasticsearch-0.7.1-py2.7.egg\pyelasticsearch\client.py", line 591, in search
    return self._search_or_count('_search', query, **kwargs)
TypeError: _search_or_count() got an unexpected keyword argument 'search_type'

1 个答案:

答案 0 :(得分:0)

看起来你有一个旧的pyleasticsearch lib,更新或者:(