Specify search type in pyelasticsearch

Is there a way to specify the type of search when using pyelasticsearch? In the documentation for "scan", "scroll", "query_and_fetch", etc. There is nothing. By running the following code:

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

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

It produces the following error:

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'
+4
source share
1 answer

It looks like you have an old pyleasticsearch lib, update, or else :(

0
source

Source: https://habr.com/ru/post/1570537/


All Articles