# Distributed search, how to work?

**URL:** https://discuss.elastic.co/t/distributed-search-how-to-work/173073
**Category:** Elasticsearch
**Created:** [March 20, 2019, 4:41am UTC](https://discuss.elastic.co/t/distributed-search-how-to-work/173073 "2019-03-20T04:41:00Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jerry-chen-315](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerry-chen-315/32/34699_2.png) [@jerry-chen-315](https://discuss.elastic.co/u/jerry-chen-315)
#### Post date: [March 20, 2019, 4:41am UTC](https://discuss.elastic.co/t/distributed-search-how-to-work/173073/1 "2019-03-20T04:41:00Z")

</div>

Hello,  
I read this document about distributed search execution:  
[https://www.elastic.co/guide/en/elasticsearch/guide/current/\_query\_phase.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/_query_phase.html)  
If query is broadcast to every shard in the index. Are there duplicate query phases on the same shard(primary and replicates)?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [March 20, 2019, 4:45am UTC](https://discuss.elastic.co/t/distributed-search-how-to-work/173073/2 "2019-03-20T04:45:15Z")

</div>

No, the search will only use one of the primary or replica.

---

<div class="post-metadata">

### Author: ![jerry-chen-315](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerry-chen-315/32/34699_2.png) [@jerry-chen-315](https://discuss.elastic.co/u/jerry-chen-315)
#### Post date: [March 20, 2019, 6:42am UTC](https://discuss.elastic.co/t/distributed-search-how-to-work/173073/3 "2019-03-20T06:42:01Z")

</div>

OK,so the search scalability is the number of primary shard?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [March 20, 2019, 9:10am UTC](https://discuss.elastic.co/t/distributed-search-how-to-work/173073/4 "2019-03-20T09:10:01Z")

</div>

It's a number of things, but that is one part of it yes.

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [March 20, 2019, 9:37am UTC](https://discuss.elastic.co/t/distributed-search-how-to-work/173073/5 "2019-03-20T09:37:21Z")

</div>

The usual way to scale up search is to add replicas, not primaries. The `number_of_replicas` setting of an index affects its capacity for search because each search of an index only goes to a single copy of each shard (i.e. either the primary or one of its replicas). If you add more replicas then each replica will serve proportionally fewer searches.

The `number_of_shards` setting of an index affects its capacity for both search and indexing. Each document that you index goes to every copy of its shard (i.e. the primary and all its replicas) so changing `number_of_replicas` doesn't affect the indexing load on each copy. However if you double the `number_of_shards` then you halve the load on each shard for both indexing and search.

The scaling is not perfect because there is overhead associated with adding extra shard copies. It doesn't work well to set these numbers to very high values in the hope that this gives you better performance. The only way to find the best performance is with careful benchmarking.

---

<div class="post-metadata">

### Author: ![jerry-chen-315](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jerry-chen-315/32/34699_2.png) [@jerry-chen-315](https://discuss.elastic.co/u/jerry-chen-315)
#### Post date: [March 29, 2019, 9:19am UTC](https://discuss.elastic.co/t/distributed-search-how-to-work/173073/6 "2019-03-29T09:19:19Z")

</div>

Thanks for your replies.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 26, 2019, 9:19am UTC](https://discuss.elastic.co/t/distributed-search-how-to-work/173073/7 "2019-04-26T09:19:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
