|
58 | 58 | - match: { _shards.failed: 0 }
|
59 | 59 | - match: { hits.total: 1 }
|
60 | 60 |
|
| 61 | +--- |
| 62 | +"Test that queries on _index field that don't match alias are skipped": |
| 63 | + |
| 64 | + - do: |
| 65 | + indices.create: |
| 66 | + index: skip_shards_local_index |
| 67 | + body: |
| 68 | + settings: |
| 69 | + index: |
| 70 | + number_of_shards: 2 |
| 71 | + number_of_replicas: 0 |
| 72 | + mappings: |
| 73 | + properties: |
| 74 | + created_at: |
| 75 | + type: date |
| 76 | + format: "yyyy-MM-dd" |
| 77 | + |
| 78 | + - do: |
| 79 | + bulk: |
| 80 | + refresh: true |
| 81 | + body: |
| 82 | + - '{"index": {"_index": "skip_shards_local_index"}}' |
| 83 | + - '{"f1": "local_cluster", "sort_field": 0, "created_at" : "2017-01-01"}' |
| 84 | + - '{"index": {"_index": "skip_shards_local_index"}}' |
| 85 | + - '{"f1": "local_cluster", "sort_field": 1, "created_at" : "2017-01-02"}' |
| 86 | + - do: |
| 87 | + indices.put_alias: |
| 88 | + index: skip_shards_local_index |
| 89 | + name: test_skip_alias |
| 90 | + |
| 91 | + # check that we match the alias with term query |
| 92 | + - do: |
| 93 | + search: |
| 94 | + track_total_hits: true |
| 95 | + index: "skip_shards_local_index" |
| 96 | + pre_filter_shard_size: 1 |
| 97 | + ccs_minimize_roundtrips: false |
| 98 | + body: { "size" : 10, "query" : { "term" : { "_index" : "test_skip_alias" } } } |
| 99 | + |
| 100 | + - match: { hits.total.value: 2 } |
| 101 | + - match: { hits.hits.0._index: "skip_shards_local_index"} |
| 102 | + - match: { _shards.total: 2 } |
| 103 | + - match: { _shards.successful: 2 } |
| 104 | + - match: { _shards.skipped : 0} |
| 105 | + - match: { _shards.failed: 0 } |
| 106 | + |
| 107 | + # check that we match the alias with terms query |
| 108 | + - do: |
| 109 | + search: |
| 110 | + track_total_hits: true |
| 111 | + index: "skip_shards_local_index" |
| 112 | + pre_filter_shard_size: 1 |
| 113 | + ccs_minimize_roundtrips: false |
| 114 | + body: { "size" : 10, "query" : { "terms" : { "_index" : ["test_skip_alias", "does_not_match"] } } } |
| 115 | + |
| 116 | + - match: { hits.total.value: 2 } |
| 117 | + - match: { hits.hits.0._index: "skip_shards_local_index"} |
| 118 | + - match: { _shards.total: 2 } |
| 119 | + - match: { _shards.successful: 2 } |
| 120 | + - match: { _shards.skipped : 0} |
| 121 | + - match: { _shards.failed: 0 } |
| 122 | + |
| 123 | + # check that we match the alias with prefix query |
| 124 | + - do: |
| 125 | + search: |
| 126 | + track_total_hits: true |
| 127 | + index: "skip_shards_local_index" |
| 128 | + pre_filter_shard_size: 1 |
| 129 | + ccs_minimize_roundtrips: false |
| 130 | + body: { "size" : 10, "query" : { "prefix" : { "_index" : "test_skip_ali" } } } |
| 131 | + |
| 132 | + - match: { hits.total.value: 2 } |
| 133 | + - match: { hits.hits.0._index: "skip_shards_local_index"} |
| 134 | + - match: { _shards.total: 2 } |
| 135 | + - match: { _shards.successful: 2 } |
| 136 | + - match: { _shards.skipped : 0} |
| 137 | + - match: { _shards.failed: 0 } |
| 138 | + |
| 139 | + # check that we match the alias with wildcard query |
| 140 | + - do: |
| 141 | + search: |
| 142 | + track_total_hits: true |
| 143 | + index: "skip_shards_local_index" |
| 144 | + pre_filter_shard_size: 1 |
| 145 | + ccs_minimize_roundtrips: false |
| 146 | + body: { "size" : 10, "query" : { "wildcard" : { "_index" : "test_skip_ali*" } } } |
| 147 | + |
| 148 | + - match: { hits.total.value: 2 } |
| 149 | + - match: { hits.hits.0._index: "skip_shards_local_index"} |
| 150 | + - match: { _shards.total: 2 } |
| 151 | + - match: { _shards.successful: 2 } |
| 152 | + - match: { _shards.skipped : 0} |
| 153 | + - match: { _shards.failed: 0 } |
| 154 | + |
| 155 | + |
| 156 | + # check that skipped when we don't match the alias with a term query |
| 157 | + - do: |
| 158 | + search: |
| 159 | + track_total_hits: true |
| 160 | + index: "skip_shards_local_index" |
| 161 | + pre_filter_shard_size: 1 |
| 162 | + ccs_minimize_roundtrips: false |
| 163 | + body: { "size" : 10, "query" : { "term" : { "_index" : "does_not_match" } } } |
| 164 | + |
| 165 | + |
| 166 | + - match: { hits.total.value: 0 } |
| 167 | + - match: { _shards.total: 2 } |
| 168 | + - match: { _shards.successful: 2 } |
| 169 | + # When all shards are skipped current logic returns 1 to produce a valid search result |
| 170 | + - match: { _shards.skipped : 1} |
| 171 | + - match: { _shards.failed: 0 } |
| 172 | + |
| 173 | + # check that skipped when we don't match the alias with a terms query |
| 174 | + - do: |
| 175 | + search: |
| 176 | + track_total_hits: true |
| 177 | + index: "skip_shards_local_index" |
| 178 | + pre_filter_shard_size: 1 |
| 179 | + ccs_minimize_roundtrips: false |
| 180 | + body: { "size" : 10, "query" : { "terms" : { "_index" : ["does_not_match", "also_does_not_match"] } } } |
| 181 | + |
| 182 | + |
| 183 | + - match: { hits.total.value: 0 } |
| 184 | + - match: { _shards.total: 2 } |
| 185 | + - match: { _shards.successful: 2 } |
| 186 | + # When all shards are skipped current logic returns 1 to produce a valid search result |
| 187 | + - match: { _shards.skipped : 1} |
| 188 | + - match: { _shards.failed: 0 } |
| 189 | + |
| 190 | + # check that skipped when we don't match the alias with a prefix query |
| 191 | + - do: |
| 192 | + search: |
| 193 | + track_total_hits: true |
| 194 | + index: "skip_shards_local_index" |
| 195 | + pre_filter_shard_size: 1 |
| 196 | + ccs_minimize_roundtrips: false |
| 197 | + body: { "size" : 10, "query" : { "prefix" : { "_index" : "does_not_matc" } } } |
| 198 | + |
| 199 | + |
| 200 | + - match: { hits.total.value: 0 } |
| 201 | + - match: { _shards.total: 2 } |
| 202 | + - match: { _shards.successful: 2 } |
| 203 | + # When all shards are skipped current logic returns 1 to produce a valid search result |
| 204 | + - match: { _shards.skipped : 1} |
| 205 | + - match: { _shards.failed: 0 } |
| 206 | + |
| 207 | + # check that skipped when we don't match the alias with a wildcard query |
| 208 | + - do: |
| 209 | + search: |
| 210 | + track_total_hits: true |
| 211 | + index: "skip_shards_local_index" |
| 212 | + pre_filter_shard_size: 1 |
| 213 | + ccs_minimize_roundtrips: false |
| 214 | + body: { "size" : 10, "query" : { "wildcard" : { "_index" : "does_not_matc*" } } } |
| 215 | + |
| 216 | + |
| 217 | + - match: { hits.total.value: 0 } |
| 218 | + - match: { _shards.total: 2 } |
| 219 | + - match: { _shards.successful: 2 } |
| 220 | + # When all shards are skipped current logic returns 1 to produce a valid search result |
| 221 | + - match: { _shards.skipped : 1} |
| 222 | + - match: { _shards.failed: 0 } |
| 223 | + |
0 commit comments