@@ -9,35 +9,29 @@ account. However, it may sometimes be desirable to try and route certain
9
9
searches to certain sets of shard copies, for instance to make better use of
10
10
per-copy caches.
11
11
12
- Preferences do not _guarantee_ that any particular shard copies are used in a
13
- search, and on a changing index this may mean that repeated searches may yield
14
- different results if they are executed on different shard copies which are in
15
- different refresh states.
16
-
17
12
The `preference` is a query string parameter which can be set to:
18
13
19
14
[horizontal]
20
15
`_primary`::
21
- The operation will be executed only on primary shards.
22
- deprecated[6.1.0, will be removed in 7.0, use `_only_nodes` or
23
- `_prefer_nodes`]
16
+ The operation will be executed only on primary shards. deprecated[6.1.0,
17
+ will be removed in 7.0. See the warning below for more information.]
24
18
25
19
`_primary_first`::
26
- The operation will be executed on primary shards if possible, but will
27
- fall back to other shards if not. deprecated[6.1.0, will be removed in
28
- 7.0, use `_only_nodes` or `_prefer_nodes` ]
20
+ The operation will be executed on primary shards if possible, but will fall
21
+ back to other shards if not. deprecated[6.1.0, will be removed in 7.0. See
22
+ the warning below for more information. ]
29
23
30
24
`_replica`::
31
- The operation will be executed only on replica shards. If there are
32
- multiple replicas then the order of preference between them is
33
- unspecified. deprecated[6.1.0, will be removed in 7.0, use
34
- `_only_nodes` or `_prefer_nodes` ]
25
+ The operation will be executed only on replica shards. If there are multiple
26
+ replicas then the order of preference between them is unspecified.
27
+ deprecated[6.1.0, will be removed in 7.0. See the warning below for more
28
+ information. ]
35
29
36
30
`_replica_first`::
37
- The operation will be executed on replica shards if possible, but will
38
- fall back to other shards if not. If there are multiple replicas then
39
- the order of preference between them is unspecified. deprecated[6.1.0,
40
- will be removed in 7.0, use `_only_nodes` or `_prefer_nodes` ]
31
+ The operation will be executed on replica shards if possible, but will fall
32
+ back to other shards if not. If there are multiple replicas then the order of
33
+ preference between them is unspecified. deprecated[6.1.0, will be removed in
34
+ 7.0. See the warning below for more information. ]
41
35
42
36
`_only_local`::
43
37
The operation will be executed only on shards allocated to the local
@@ -72,8 +66,9 @@ Custom (string) value::
72
66
each time: the cluster state, and therefore the selected shards, may change
73
67
for a number of reasons including shard relocations and shard failures, and
74
68
nodes may sometimes reject searches causing fallbacks to alternative nodes.
75
- A good candidate for a custom preference value is something like the web
76
- session id or the user name.
69
+ However, in practice the ordering of shards tends to remain stable for long
70
+ periods of time. A good candidate for a custom preference value is something
71
+ like the web session id or the user name.
77
72
78
73
For instance, use the user's session ID `xyzabc123` as follows:
79
74
@@ -90,12 +85,22 @@ GET /_search?preference=xyzabc123
90
85
------------------------------------------------
91
86
// CONSOLE
92
87
88
+ NOTE: The `_only_local` preference guarantees only to use shard copies on the
89
+ local node, which is sometimes useful for troubleshooting. All other options do
90
+ not _fully_ guarantee that any particular shard copies are used in a search,
91
+ and on a changing index this may mean that repeated searches may yield
92
+ different results if they are executed on different shard copies which are in
93
+ different refresh states.
94
+
93
95
WARNING: The `_primary`, `_primary_first`, `_replica` and `_replica_first` are
94
- not recommended, and will be removed in a future version. They do not help to
95
- avoid inconsistent results that arise from the use of shards that have
96
- different refresh states, and Elasticsearch uses synchronous replication so the
97
- primary does not in general hold fresher data than its replicas. The
98
- `_primary_first` and `_replica_first` preferences silently fall back to
99
- non-preferred copies if it is not possible to search the preferred copies. The
100
- `_primary` and `_replica` preferences will silently change their preferred
101
- shards if a replica is promoted to primary, which can happen at any time.
96
+ deprecated as their use is not recommended. They do not help to avoid
97
+ inconsistent results that arise from the use of shards that have different
98
+ refresh states, and Elasticsearch uses synchronous replication so the primary
99
+ does not in general hold fresher data than its replicas. The `_primary_first`
100
+ and `_replica_first` preferences silently fall back to non-preferred copies if
101
+ it is not possible to search the preferred copies. The `_primary` and
102
+ `_replica` preferences will silently change their preferred shards if a replica
103
+ is promoted to primary, which can happen at any time. The `_primary` preference
104
+ can also put undesirable extra load on the primary shards. The cache-related
105
+ benefits of these options can also be obtained using `_only_nodes`,
106
+ `_prefer_nodes`, or a custom string value instead.
0 commit comments