# Dont work preference in es version 6

**URL:** <https://discuss.elastic.co/t/dont-work-preference-in-es-version-6/339756>\
**Category:** Elasticsearch\
**Created:** [August 1, 2023, 7:12am UTC](https://discuss.elastic.co/t/dont-work-preference-in-es-version-6/339756 "2023-08-01T07:12:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![slowup](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/slowup/32/99097_2.png) [@slowup](https://discuss.elastic.co/u/slowup)\
**Post date:** [August 1, 2023, 7:12am UTC](https://discuss.elastic.co/t/dont-work-preference-in-es-version-6/339756/1 "2023-08-01T07:12:03Z")

</div>

I know that the preference custome string is a function that allows you to search with the same shard, but every time you search, a different shard is searched, so the search results of search after are strange.  
What should I do?

```auto
search
indexname/_search?search_type=dfs_query_then_fetch&preference=hahahoho
{
  "sort": [
    {
      "_score": {
        "order": "desc"
      }
    },
    {
      "id": {
        "order": "desc"
      }
    }
  ], 
   "search_after": [value, value]
}

response
"_shard" : "[indexname][1]",
"_node" : "U7VmOV3ARkSuzMD1TcBvog",

or

"_shard" : "[indexname][1]",
"_node" : "hVZTf0ekRim3kAMKdPjBRg"

```

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [August 1, 2023, 10:06am UTC](https://discuss.elastic.co/t/dont-work-preference-in-es-version-6/339756/2 "2023-08-01T10:06:46Z")

</div>

Hi @slowup,

The `preference` option does have a `_shards` option [as per the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/search-request-preference.html). It doesn't look like the example usage `_shards:2,3` matches the string in your example. Have you also made sure that the shards option is listed first?

Can I confirm that you're using Elasticsearch v6.x? That version is past EOL so we would strongly recommend upgrading if you can.

---

<div class="post-metadata">

**Author:** ![slowup](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/slowup/32/99097_2.png) [@slowup](https://discuss.elastic.co/u/slowup)\
**Post date:** [August 1, 2023, 12:22pm UTC](https://discuss.elastic.co/t/dont-work-preference-in-es-version-6/339756/3 "2023-08-01T12:22:44Z")

</div>

hi @carly.richmond  
thank u  
I used Custom (string) value  
Looking at the docs it says sending to the same shard, of course not always

---

<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:** [August 29, 2023, 12:23pm UTC](https://discuss.elastic.co/t/dont-work-preference-in-es-version-6/339756/4 "2023-08-29T12:23:32Z")

</div>

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