在ElasticSearch中使用切片扫描python助手

p1iqtdky  于 2022-12-22  发布在  ElasticSearch
关注(0)|答案(2)|浏览(104)

下面的代码:

client = Elasticsearch(hosts=['host'], port=9200)
scan_arguments = {'query': {'slice': {'max': 1, 'id': 0}}, 'preference': '_shards:0', 'index': u'my_index'}

for hit in scan(client, **scan_args):
    # do something with hit

得到了以下错误

RequestError: TransportError(400, u'parsing_exception', u'[slice] failed to parse field [max]')

在扫描函数中应该如何传递切片参数?

slsn1g29

slsn1g291#

根据我的经验,“max”需要〉1。我以前在使用“max”时也看到过同样的错误:1。

jjhzyzn0

jjhzyzn02#

HTTP API的原始错误显示max必须大于1。

{
  "error": {
    "root_cause": [
      {
        "type": "x_content_parse_exception",
        "reason": "[3:20] [slice] failed to parse field [max]"
      }
    ],
    "type": "x_content_parse_exception",
    "reason": "[3:20] [slice] failed to parse field [max]",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "max must be greater than 1"
    }
  },
  "status": 400
}

相关问题