Ben ODay
Ben ODay

Reputation: 21005

can I query for documents in specific Elasticsearch shard?

we are using custom routing and ended up with a single shard that is over 100gb and I'd like to know which routing value is causing this imbalance...

I can see the shards like this...

GET /_cat/shards

my-index 2 p STARTED 10108264 131.5gb  
my-index 3 p STARTED   270403   1.7gb 
my-index 1 p STARTED   187303   1.5gb 
my-index 0 p STARTED   321519   2.5gb 

and see the shard details like this..

GET /my-index/_search_shards

and even see shard info for random documents like this...

GET /my-index/_search
{
  "explain": true
} 

but how can I search for documents in a specific shard (shard #2 in my case)?

Upvotes: 8

Views: 7507

Answers (1)

keety
keety

Reputation: 17441

Should be able to do that using the preference option:

Example:

GET my-index/_search?preference=_shards:2

Upvotes: 17

Related Questions