【问题标题】:Eland - TypeError: count() got an unexpected keyword argument 'query'Eland - TypeError:count() 得到了一个意外的关键字参数 \'query\'
【发布时间】:2022-10-25 22:07:05
【问题描述】:

我正在尝试使用 Python 中的 Eland API 将我的 ES 索引作为数据框。 但是,我遇到了打字错误。


    es = Elasticsearch(hosts=["http://1.1.1.1:9100"], send_get_body_as='POST', http_auth=('es-automation',
                                                                                            'my_password'))
    
    import eland as ed
    ed.DataFrame(es, es_index_pattern='es_index')

TypeError                                 Traceback (most recent call last)
~/shivamenv/venv/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
    700                 type_pprinters=self.type_printers,
    701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
    703             printer.flush()
    704             return stream.getvalue()

~/shivamenv/venv/lib/python3.7/site-packages/IPython/lib/pretty.py in pretty(self, obj)
    392                         if cls is not object \
    393                                 and callable(cls.__dict__.get('__repr__')):
--> 394                             return _repr_pprint(obj, self, cycle)
    395 
    396             return _default_pprint(obj, self, cycle)

~/shivamenv/venv/lib/python3.7/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
    698     """A pprint that just redirects to the normal repr function."""
    699     # Find newlines and replace them with p.break_()
--> 700     output = repr(obj)
    701     lines = output.splitlines()
    702     with p.group():

~/shivamenv/venv/lib/python3.7/site-packages/eland/dataframe.py in __repr__(self)
    492         min_rows = pd.get_option("display.min_rows")
    493 
--> 494         if max_rows and len(self) > max_rows:
    495             max_rows = min_rows
    496 

~/shivamenv/venv/lib/python3.7/site-packages/eland/ndframe.py in __len__(self)
    185             Returns an integer length of the DataFrame object.
    186         """
--> 187         return len(self.index)
    188 
    189     def _es_info(self, buf: TextIO) -> None:

~/shivamenv/venv/lib/python3.7/site-packages/eland/index.py in __len__(self)
     80 
     81     def __len__(self) -> int:
---> 82         return self._query_compiler._index_count()
     83 
     84     # Make iterable

~/shivamenv/venv/lib/python3.7/site-packages/eland/query_compiler.py in _index_count(self)
    358             Count of docs where index_field exists
    359         """
--> 360         return self._operations.index_count(self, self.index.es_index_field)
    361 
    362     def _index_matches_count(self, items: List[Any]) -> int:

~/shivamenv/venv/lib/python3.7/site-packages/eland/operations.py in index_count(self, query_compiler, field)
   1273 
   1274         count: int = query_compiler._client.count(
-> 1275             index=query_compiler._index_pattern, **body.to_count_body()
   1276         )["count"]
   1277         return count

~/shivamenv/venv/lib/python3.7/site-packages/elasticsearch/client/utils.py in _wrapped(*args, **kwargs)
     99                 if p in kwargs:
    100                     params[p] = kwargs.pop(p)
--> 101             return func(*args, params=params, **kwargs)
    102 
    103         return _wrapped

TypeError: count() got an unexpected keyword argument 'query'

这里出了什么问题?我尝试了各种指数 - 仍然是同样的问题。

我的版本

伊兰==8.0.0

弹性传输==8.0.1

弹性搜索==6.8.2

弹性搜索-dsl==7.4.0

弹性搜索7==7.17.0

【问题讨论】:

    标签: python python-3.x http elasticsearch eland


    【解决方案1】:

    尝试降级所有支持的库以适合您的 ES 服务器版本(ealsticsearch==7.16;eland==7.16;pandas==1.2.x ...)

    【讨论】:

      猜你喜欢
      • 2016-09-17
      • 2015-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-13
      • 2021-03-17
      • 2020-10-01
      • 2018-06-19
      相关资源
      最近更新 更多