Apostolos
Apostolos

Reputation: 8121

scan python helper in elasticsearch with slice

I have the following code:

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

and I get the following error

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

How should the slice parameter be passed in the scan function?

Upvotes: 1

Views: 1067

Answers (2)

mpalumbo7
mpalumbo7

Reputation: 1390

The raw error from the HTTP API says max must be greater than 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
}

Upvotes: 0

yawl
yawl

Reputation: 728

"max" needs to be >1 in my experience. I saw the same error before when using "max":1.

Upvotes: 3

Related Questions