|
| 1 | +setup: |
| 2 | + - requires: |
| 3 | + cluster_features: [ "rrf_retriever.multi_fields_query_format_support" ] |
| 4 | + reason: "RRF retriever multi-fields query format support" |
| 5 | + test_runner_features: [ "contains" ] |
| 6 | + |
| 7 | + - do: |
| 8 | + inference.put: |
| 9 | + task_type: sparse_embedding |
| 10 | + inference_id: sparse-inference-id |
| 11 | + body: > |
| 12 | + { |
| 13 | + "service": "test_service", |
| 14 | + "service_settings": { |
| 15 | + "model": "my_model", |
| 16 | + "api_key": "abc64" |
| 17 | + }, |
| 18 | + "task_settings": { |
| 19 | + } |
| 20 | + } |
| 21 | +
|
| 22 | + - do: |
| 23 | + inference.put: |
| 24 | + task_type: text_embedding |
| 25 | + inference_id: dense-inference-id |
| 26 | + body: > |
| 27 | + { |
| 28 | + "service": "text_embedding_test_service", |
| 29 | + "service_settings": { |
| 30 | + "model": "my_model", |
| 31 | + "dimensions": 128, |
| 32 | + "similarity": "cosine", |
| 33 | + "api_key": "abc64" |
| 34 | + }, |
| 35 | + "task_settings": { |
| 36 | + } |
| 37 | + } |
| 38 | +
|
| 39 | + - do: |
| 40 | + indices.create: |
| 41 | + index: test-index |
| 42 | + body: |
| 43 | + mappings: |
| 44 | + properties: |
| 45 | + keyword: |
| 46 | + type: keyword |
| 47 | + dense_inference: |
| 48 | + type: semantic_text |
| 49 | + inference_id: dense-inference-id |
| 50 | + sparse_inference: |
| 51 | + type: semantic_text |
| 52 | + inference_id: sparse-inference-id |
| 53 | + text_1: |
| 54 | + type: text |
| 55 | + text_2: |
| 56 | + type: text |
| 57 | + timestamp: |
| 58 | + type: date |
| 59 | + dense_vector: |
| 60 | + type: dense_vector |
| 61 | + dims: 1 |
| 62 | + index: true |
| 63 | + similarity: l2_norm |
| 64 | + index_options: |
| 65 | + type: flat |
| 66 | + sparse_vector: |
| 67 | + type: sparse_vector |
| 68 | + |
| 69 | + - do: |
| 70 | + bulk: |
| 71 | + index: test-index |
| 72 | + refresh: true |
| 73 | + body: | |
| 74 | + {"index": {"_id": "1"}} |
| 75 | + { |
| 76 | + "keyword": "keyword match 1", |
| 77 | + "dense_inference": "you know", |
| 78 | + "sparse_inference": "for testing", |
| 79 | + "text_1": "foo match 1", |
| 80 | + "text_2": "x match 2", |
| 81 | + "timestamp": "2000-03-30", |
| 82 | + "dense_vector": [1], |
| 83 | + "sparse_vector": { |
| 84 | + "foo": 1.0 |
| 85 | + } |
| 86 | + } |
| 87 | + {"index": {"_id": "2"}} |
| 88 | + { |
| 89 | + "keyword": "keyword match 2", |
| 90 | + "dense_inference": "ElasticSearch is an open source", |
| 91 | + "sparse_inference": "distributed, RESTful, search engine", |
| 92 | + "text_1": "bar match 3", |
| 93 | + "text_2": "y match 4", |
| 94 | + "timestamp": "2010-02-08", |
| 95 | + "dense_vector": [2], |
| 96 | + "sparse_vector": { |
| 97 | + "bar": 1.0 |
| 98 | + } |
| 99 | + } |
| 100 | + {"index": {"_id": "3"}} |
| 101 | + { |
| 102 | + "keyword": "keyword match 3", |
| 103 | + "dense_inference": "which is built on top of Lucene internally", |
| 104 | + "sparse_inference": "and enjoys all the features it provides", |
| 105 | + "text_1": "baz match 5", |
| 106 | + "text_2": "z match 6", |
| 107 | + "timestamp": "2024-08-08", |
| 108 | + "dense_vector": [3], |
| 109 | + "sparse_vector": { |
| 110 | + "baz": 1.0 |
| 111 | + } |
| 112 | + } |
| 113 | +
|
| 114 | +--- |
| 115 | +"Query all fields using the simplified format": |
| 116 | + - do: |
| 117 | + search: |
| 118 | + index: test-index |
| 119 | + body: |
| 120 | + retriever: |
| 121 | + rrf: |
| 122 | + query: "match" |
| 123 | + |
| 124 | + - match: { hits.total.value: 3 } |
| 125 | + - length: { hits.hits: 3 } |
| 126 | + - match: { hits.hits.0._id: "2" } |
| 127 | + - match: { hits.hits.1._id: "1" } |
| 128 | + - match: { hits.hits.2._id: "3" } |
| 129 | + |
| 130 | +--- |
| 131 | +"Per-field boosting is not supported": |
| 132 | + - do: |
| 133 | + catch: bad_request |
| 134 | + search: |
| 135 | + index: test-index |
| 136 | + body: |
| 137 | + retriever: |
| 138 | + rrf: |
| 139 | + fields: [ "text_1", "text_2^3" ] |
| 140 | + query: "foo" |
| 141 | + |
| 142 | + - match: { error.root_cause.0.reason: "[rrf] does not support per-field weights in [fields]" } |
| 143 | + |
| 144 | +--- |
| 145 | +"Can query keyword fields": |
| 146 | + - do: |
| 147 | + search: |
| 148 | + index: test-index |
| 149 | + body: |
| 150 | + retriever: |
| 151 | + rrf: |
| 152 | + fields: [ "keyword" ] |
| 153 | + query: "keyword match 1" |
| 154 | + |
| 155 | + - match: { hits.total.value: 1 } |
| 156 | + - length: { hits.hits: 1 } |
| 157 | + - match: { hits.hits.0._id: "1" } |
| 158 | + |
| 159 | +--- |
| 160 | +"Can query date fields": |
| 161 | + - do: |
| 162 | + search: |
| 163 | + index: test-index |
| 164 | + body: |
| 165 | + retriever: |
| 166 | + rrf: |
| 167 | + fields: [ "timestamp" ] |
| 168 | + query: "2010-02-08" |
| 169 | + |
| 170 | + - match: { hits.total.value: 1 } |
| 171 | + - length: { hits.hits: 1 } |
| 172 | + - match: { hits.hits.0._id: "2" } |
| 173 | + |
| 174 | +--- |
| 175 | +"Can query sparse vector fields": |
| 176 | + - do: |
| 177 | + search: |
| 178 | + index: test-index |
| 179 | + body: |
| 180 | + retriever: |
| 181 | + rrf: |
| 182 | + fields: [ "sparse_vector" ] |
| 183 | + query: "foo" |
| 184 | + |
| 185 | + - match: { hits.total.value: 1 } |
| 186 | + - length: { hits.hits: 1 } |
| 187 | + - match: { hits.hits.0._id: "1" } |
| 188 | + |
| 189 | +--- |
| 190 | +"Cannot query dense vector fields": |
| 191 | + - do: |
| 192 | + catch: bad_request |
| 193 | + search: |
| 194 | + index: test-index |
| 195 | + body: |
| 196 | + retriever: |
| 197 | + rrf: |
| 198 | + fields: [ "dense_vector" ] |
| 199 | + query: "foo" |
| 200 | + |
| 201 | + - contains: { error.root_cause.0.reason: "[rrf] search failed - retrievers '[standard]' returned errors" } |
| 202 | + - contains: { error.root_cause.0.suppressed.0.failed_shards.0.reason.reason: "Field [dense_vector] of type [dense_vector] does not support match queries" } |
| 203 | + |
| 204 | +--- |
| 205 | +"Filters are propagated": |
| 206 | + - do: |
| 207 | + search: |
| 208 | + index: test-index |
| 209 | + body: |
| 210 | + retriever: |
| 211 | + rrf: |
| 212 | + query: "match" |
| 213 | + filter: |
| 214 | + - term: |
| 215 | + keyword: "keyword match 1" |
| 216 | + |
| 217 | + - match: { hits.total.value: 1 } |
| 218 | + - length: { hits.hits: 1 } |
| 219 | + - match: { hits.hits.0._id: "1" } |
| 220 | + |
| 221 | +--- |
| 222 | +"Wildcard index patterns that do not resolve to any index are handled gracefully": |
| 223 | + - do: |
| 224 | + search: |
| 225 | + index: wildcard-* |
| 226 | + body: |
| 227 | + retriever: |
| 228 | + rrf: |
| 229 | + query: "match" |
| 230 | + |
| 231 | + - match: { hits.total.value: 0 } |
| 232 | + - length: { hits.hits: 0 } |
| 233 | + |
| 234 | +--- |
| 235 | +"Multi-index searches are not allowed": |
| 236 | + - do: |
| 237 | + indices.create: |
| 238 | + index: test-index-2 |
| 239 | + |
| 240 | + - do: |
| 241 | + catch: bad_request |
| 242 | + search: |
| 243 | + index: [ test-index, test-index-2 ] |
| 244 | + body: |
| 245 | + retriever: |
| 246 | + rrf: |
| 247 | + query: "match" |
| 248 | + |
| 249 | + - match: { error.root_cause.0.reason: "[rrf] cannot specify [query] when querying multiple indices" } |
| 250 | + |
| 251 | + - do: |
| 252 | + indices.put_alias: |
| 253 | + index: test-index |
| 254 | + name: test-alias |
| 255 | + - do: |
| 256 | + indices.put_alias: |
| 257 | + index: test-index-2 |
| 258 | + name: test-alias |
| 259 | + |
| 260 | + - do: |
| 261 | + catch: bad_request |
| 262 | + search: |
| 263 | + index: test-alias |
| 264 | + body: |
| 265 | + retriever: |
| 266 | + rrf: |
| 267 | + query: "match" |
| 268 | + |
| 269 | + - match: { error.root_cause.0.reason: "[rrf] cannot specify [query] when querying multiple indices" } |
| 270 | + |
| 271 | +--- |
| 272 | +"Wildcard field patterns that do not resolve to any field are handled gracefully": |
| 273 | + - do: |
| 274 | + search: |
| 275 | + index: test-index |
| 276 | + body: |
| 277 | + retriever: |
| 278 | + rrf: |
| 279 | + fields: [ "wildcard-*" ] |
| 280 | + query: "match" |
| 281 | + |
| 282 | + - match: { hits.total.value: 0 } |
| 283 | + - length: { hits.hits: 0 } |
| 284 | + |
| 285 | +--- |
| 286 | +"Cannot mix simplified query format with custom sub-retrievers": |
| 287 | + - do: |
| 288 | + catch: bad_request |
| 289 | + search: |
| 290 | + index: test-index |
| 291 | + body: |
| 292 | + retriever: |
| 293 | + rrf: |
| 294 | + query: "foo" |
| 295 | + retrievers: |
| 296 | + - standard: |
| 297 | + query: |
| 298 | + match: |
| 299 | + keyword: "bar" |
| 300 | + |
| 301 | + - contains: { error.root_cause.0.reason: "[rrf] cannot combine [retrievers] and [query]" } |
| 302 | + |
| 303 | +--- |
| 304 | +"Missing required params": |
| 305 | + - do: |
| 306 | + catch: bad_request |
| 307 | + search: |
| 308 | + index: test-index |
| 309 | + body: |
| 310 | + retriever: |
| 311 | + rrf: |
| 312 | + fields: [ "text_1", "text_2" ] |
| 313 | + |
| 314 | + - contains: { error.root_cause.0.reason: "[rrf] [query] must be provided when [fields] is specified" } |
| 315 | + |
| 316 | + - do: |
| 317 | + catch: bad_request |
| 318 | + search: |
| 319 | + index: test-index |
| 320 | + body: |
| 321 | + retriever: |
| 322 | + rrf: |
| 323 | + fields: [ "text_1", "text_2" ] |
| 324 | + query: "" |
| 325 | + |
| 326 | + - contains: { error.root_cause.0.reason: "[rrf] [query] cannot be empty" } |
| 327 | + |
| 328 | + - do: |
| 329 | + catch: bad_request |
| 330 | + search: |
| 331 | + index: test-index |
| 332 | + body: |
| 333 | + retriever: |
| 334 | + rrf: {} |
| 335 | + |
| 336 | + - contains: { error.root_cause.0.reason: "[rrf] must provide [retrievers] or [query]" } |
0 commit comments