# Why is preference a parameter only and not part of the request body itself?

**URL:** <https://discuss.elastic.co/t/why-is-preference-a-parameter-only-and-not-part-of-the-request-body-itself/207740>\
**Category:** Elasticsearch\
**Created:** [November 13, 2019, 4:04pm UTC](https://discuss.elastic.co/t/why-is-preference-a-parameter-only-and-not-part-of-the-request-body-itself/207740 "2019-11-13T16:04:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![usteidj](https://avatars.discourse-cdn.com/v4/letter/u/ee59a6/32.png) [@usteidj](https://discuss.elastic.co/u/usteidj)\
**Post date:** [November 13, 2019, 4:04pm UTC](https://discuss.elastic.co/t/why-is-preference-a-parameter-only-and-not-part-of-the-request-body-itself/207740/1 "2019-11-13T16:04:32Z")

</div>

I'd like to be able to pass in preference as part of the body of the request, like "from", "size", "\_source", "query", etc., but it appears that is not an option. Why?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [November 13, 2019, 4:16pm UTC](https://discuss.elastic.co/t/why-is-preference-a-parameter-only-and-not-part-of-the-request-body-itself/207740/2 "2019-11-13T16:16:42Z")

</div>

In the case of Kibana it allows a single piece of code to direct all requests from a user to the same choice of replica. This helps hit warm caches.  
Multiple parts of Kibana create different request bodies so I can see that having the routing logic in the header helps keeps these responsibilities separated. The same is true of "timeout" settings - these are typically global policies, regardless of request bodies.

---

<div class="post-metadata">

**Author:** ![usteidj](https://avatars.discourse-cdn.com/v4/letter/u/ee59a6/32.png) [@usteidj](https://discuss.elastic.co/u/usteidj)\
**Post date:** [November 13, 2019, 5:02pm UTC](https://discuss.elastic.co/t/why-is-preference-a-parameter-only-and-not-part-of-the-request-body-itself/207740/3 "2019-11-13T17:02:12Z")

</div>

I'm not sure I'm following the "this needs to be a global policy" logic because if I want to always just keep my endpoint as "\_search", I can't do this if I have to dynamically build the "preference" parameter to have a user-session id; it's the same type of thing that I'd build based upon other parts of the request body, such as "from" or "query", so I guess I'll ask: why can't preference go in the request body?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [November 13, 2019, 5:06pm UTC](https://discuss.elastic.co/t/why-is-preference-a-parameter-only-and-not-part-of-the-request-body-itself/207740/4 "2019-11-13T17:06:56Z")

</div>

I'm guessing the analogy might be the post office not wanting to open your mail.  
It just stamps any routing info on the envelope when delivering the mail.

It's also why the bulk indexing API puts routing info like index name and doc ID on a line separate from the JSON body - it helps avoid an unnecessary parsing of content being routed for delivery.

---

<div class="post-metadata">

**Author:** ![usteidj](https://avatars.discourse-cdn.com/v4/letter/u/ee59a6/32.png) [@usteidj](https://discuss.elastic.co/u/usteidj)\
**Post date:** [November 13, 2019, 5:24pm UTC](https://discuss.elastic.co/t/why-is-preference-a-parameter-only-and-not-part-of-the-request-body-itself/207740/5 "2019-11-13T17:24:20Z")

</div>

Ok. Thanks.

---

<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:** [December 11, 2019, 5:24pm UTC](https://discuss.elastic.co/t/why-is-preference-a-parameter-only-and-not-part-of-the-request-body-itself/207740/6 "2019-12-11T17:24:25Z")

</div>

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