elasticsearch/elasticsearch — pull request #3268 by Paikan (2013-06-30 17:23:06+00:00)
Title: Fix search shards count method when targeting concrete and aliased indices

This is related to the same example as issue #2682.

This bug can lead to a forced query_and_fetch search type which might not be the expected behavior.

I propose to fix it this way because it is a quick 2 lines patch. But maybe we should refactor a bit and add a shared method for searchShards and searchShardsCount to avoid divergent behavior in the future.

Reading the code it seems like searchShardsCount is mainly implemented to test if we are hitting 1 shard or more than 1 shards so maybe it could be renamed and optimized for that specific use case.

Feel free to fix the problem otherwise or to tell me what do you prefer and I will be happy to change this pull request.