Dont work preference in es version 6

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?

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"

Hi @slowup,

The preference option does have a _shards option as per the documentation. 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.

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

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