# Failover with custom search preference

**URL:** <https://discuss.elastic.co/t/failover-with-custom-search-preference/13364>\
**Category:** Elasticsearch\
**Created:** [August 28, 2013, 11:59am UTC](https://discuss.elastic.co/t/failover-with-custom-search-preference/13364 "2013-08-28T11:59:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Peschlow](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@Patrick\_Peschlow](https://discuss.elastic.co/u/Patrick_Peschlow)\
**Post date:** [August 28, 2013, 11:59am UTC](https://discuss.elastic.co/t/failover-with-custom-search-preference/13364/1 "2013-08-28T11:59:14Z")

</div>

The search preference documentation on  
[http://www.elasticsearch.org/guide/reference/api/search/preference/](http://www.elasticsearch.org/guide/reference/api/search/preference/) states  
that a custom (string) preference is supported. However, it does not  
explicitly state how possible failovers are handled in that case. Suppose  
that a custom preference value "user-1234" is currently (internally)  
associated with shard 1. What happens if shard 1 then goes down? WIll  
search queries with preference value "user-1234" also fail from that point  
onwards, or will it fail over, i.e., those custom preferences affected will  
get re-mapped internally to other shards?

Thanks for any insights,  
Patrick

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![yarin](https://avatars.discourse-cdn.com/v4/letter/y/6a8cbe/32.png) [@yarin](https://discuss.elastic.co/u/yarin)\
**Post date:** [December 15, 2013, 1:49pm UTC](https://discuss.elastic.co/t/failover-with-custom-search-preference/13364/2 "2013-12-15T13:49:15Z")

</div>

I'm also really interested in the answer for Patrick's question.

Bumping this in hope to get some answer.

Thanks in advance,  
Yarin.

On Wednesday, August 28, 2013 2:59:14 PM UTC+3, Patrick Peschlow wrote:

> The search preference documentation on  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/preference/states) that a custom (string) preference is supported. However, it does not  
> explicitly state how possible failovers are handled in that case. Suppose  
> that a custom preference value "user-1234" is currently (internally)  
> associated with shard 1. What happens if shard 1 then goes down? WIll  
> search queries with preference value "user-1234" also fail from that point  
> onwards, or will it fail over, i.e., those custom preferences affected will  
> get re-mapped internally to other shards?
> 
> Thanks for any insights,  
> Patrick

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/219831d5-07e8-4764-af87-ff3d51b88bce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/219831d5-07e8-4764-af87-ff3d51b88bce%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Patrick\_Peschlow](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@Patrick\_Peschlow](https://discuss.elastic.co/u/Patrick_Peschlow)\
**Post date:** [December 16, 2013, 8:56am UTC](https://discuss.elastic.co/t/failover-with-custom-search-preference/13364/3 "2013-12-16T08:56:59Z")

</div>

Hi Yarin,

when no one replied, I delved into the Elasticsearch source code to find  
the answer myself. What I concluded from the code is that - assuming there  
are N data nodes available in the cluster - the custom preference value is  
transformed and eventually mapped to an index 0 .. N-1 via modulo. This  
way, as long as the available nodes do not change, the queries will get  
routed to the same node.

However, once a node leaves the cluster or another one joins, the index  
resulting from the transformation may change and thus queries using the  
same custom preference may get routed to another node. This implies that

1. there is a failover of the custom preference mechanism, as long as there  
is at least one node available
2. the preferred node may change whenever the set of available data nodes  
changes (not necessarily when _that_ preferred node goes down but it can  
happen even when any node leaves or joins)

I hope that clarifies the issue for you. And if my understanding of the  
code turns out to be wrong, I'll be glad to learn about it 🙂

-Patrick

On Sunday, December 15, 2013 2:49:15 PM UTC+1, Yarin Miran wrote:

> I'm also really interested in the answer for Patrick's question.
> 
> Bumping this in hope to get some answer.
> 
> Thanks in advance,  
> Yarin.
> 
> On Wednesday, August 28, 2013 2:59:14 PM UTC+3, Patrick Peschlow wrote:
> 
> > The search preference documentation on  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/preference/states) that a custom (string) preference is supported. However, it does not  
> > explicitly state how possible failovers are handled in that case. Suppose  
> > that a custom preference value "user-1234" is currently (internally)  
> > associated with shard 1. What happens if shard 1 then goes down? WIll  
> > search queries with preference value "user-1234" also fail from that point  
> > onwards, or will it fail over, i.e., those custom preferences affected will  
> > get re-mapped internally to other shards?
> > 
> > Thanks for any insights,  
> > Patrick

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a9cefab3-11c6-45e0-a6c9-ea047d5583df%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a9cefab3-11c6-45e0-a6c9-ea047d5583df%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:01am UTC](https://discuss.elastic.co/t/failover-with-custom-search-preference/13364/4 "2017-07-06T02:01:05Z")

</div>


