简体   繁体   中英

Elasticsearch: empty slices when using scroll api with slice

I have a simple setup with a green cluster (v7.5.2) of 1 instance with 1 index (replica 0) with 8 shards. 61,500 documents indexed.

If I create 8 slices with these queries (POST queries)

http://localhost:9202/products_dev/_search?scroll=10m: {'slice': {'field': 'created_at', 'id': 0, 'max': 8}, 'size': 1000}
http://localhost:9202/products_dev/_search?scroll=10m: {'slice': {'field': 'created_at', 'id': 1, 'max': 8}, 'size': 1000}
...
http://localhost:9202/products_dev/_search?scroll=10m: {'slice': {'field': 'created_at', 'id': 7, 'max': 8}, 'size': 1000}

for each slice I collect the first hits of each slice and get those lengths: [1000, 0, 0, 0, 0, 0, 0, 0]

Only 1 slice has results which is equivalent to not slicing the index in the first place.

I tried a max of 32 with those commands:

http://localhost:9202/products_dev/_search?scroll=10m: {'slice': {'field': 'created_at', 'id': 0, 'max': 32}, 'size': 1000}
http://localhost:9202/products_dev/_search?scroll=10m: {'slice': {'field': 'created_at', 'id': 1, 'max': 32}, 'size': 1000}
...
http://localhost:9202/products_dev/_search?scroll=10m: {'slice': {'field': 'created_at', 'id': 31, 'max': 32}, 'size': 1000}

for each slice I collect the first hits of each slice and get those lengths: [1000, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 0]

This way I can scroll my index using 4 different (non-empty) slices but I had to create 32 contexts which is not ideal.

What am I doing wrong?

I tried to use a date as slice.field

"slice": {
        "field": "created_at",

but it did not help.

My local index had so few documents, most of the documents where saved in 1 shard

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM