Blame view

tests/test_search_rerank_window.py 20 KB
5f7d7f09   tangwang   性能测试报告.md
1
2
3
4
5
6
7
  from __future__ import annotations
  
  from dataclasses import dataclass
  from pathlib import Path
  from types import SimpleNamespace
  from typing import Any, Dict, List
  
deccd68a   tangwang   Added the SKU pre...
8
  import numpy as np
5f7d7f09   tangwang   性能测试报告.md
9
10
11
12
13
14
15
  import yaml
  
  from config import (
      ConfigLoader,
      FunctionScoreConfig,
      IndexConfig,
      QueryConfig,
5f7d7f09   tangwang   性能测试报告.md
16
17
18
19
20
      RerankConfig,
      SPUConfig,
      SearchConfig,
  )
  from context import create_request_context
cda1cd62   tangwang   意图分析&应用 baseline
21
  from query.style_intent import DetectedStyleIntent, StyleIntentProfile
5f7d7f09   tangwang   性能测试报告.md
22
23
24
25
26
27
28
29
30
31
32
33
  from search.searcher import Searcher
  
  
  @dataclass
  class _FakeParsedQuery:
      original_query: str
      query_normalized: str
      rewritten_query: str
      detected_language: str = "en"
      translations: Dict[str, str] = None
      query_vector: Any = None
      domain: str = "default"
cda1cd62   tangwang   意图分析&应用 baseline
34
      style_intent_profile: Any = None
5f7d7f09   tangwang   性能测试报告.md
35
36
37
38
39
40
41
42
43
  
      def to_dict(self) -> Dict[str, Any]:
          return {
              "original_query": self.original_query,
              "query_normalized": self.query_normalized,
              "rewritten_query": self.rewritten_query,
              "detected_language": self.detected_language,
              "translations": self.translations or {},
              "domain": self.domain,
cda1cd62   tangwang   意图分析&应用 baseline
44
45
46
              "style_intent_profile": (
                  self.style_intent_profile.to_dict() if self.style_intent_profile is not None else None
              ),
5f7d7f09   tangwang   性能测试报告.md
47
48
49
          }
  
  
cda1cd62   tangwang   意图分析&应用 baseline
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  def _build_style_intent_profile(intent_type: str, canonical_value: str, *dimension_aliases: str) -> StyleIntentProfile:
      aliases = dimension_aliases or (intent_type,)
      return StyleIntentProfile(
          intents=(
              DetectedStyleIntent(
                  intent_type=intent_type,
                  canonical_value=canonical_value,
                  matched_term=canonical_value,
                  matched_query_text=canonical_value,
                  dimension_aliases=tuple(aliases),
              ),
          )
      )
  
  
5f7d7f09   tangwang   性能测试报告.md
65
  class _FakeQueryParser:
ef5baa86   tangwang   混杂语言处理
66
67
68
69
70
71
72
73
      def parse(
          self,
          query: str,
          tenant_id: str,
          generate_vector: bool,
          context: Any,
          target_languages: Any = None,
      ):
5f7d7f09   tangwang   性能测试报告.md
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
          return _FakeParsedQuery(
              original_query=query,
              query_normalized=query,
              rewritten_query=query,
              translations={},
          )
  
  
  class _FakeQueryBuilder:
      def build_query(self, **kwargs):
          return {
              "query": {"match_all": {}},
              "size": kwargs["size"],
              "from": kwargs["from_"],
          }
  
      def build_facets(self, facets: Any):
          return {}
  
      def add_sorting(self, es_query: Dict[str, Any], sort_by: str, sort_order: str):
          return es_query
  
  
  class _FakeESClient:
      def __init__(self, total_hits: int = 5000):
          self.calls: List[Dict[str, Any]] = []
          self.total_hits = total_hits
  
      @staticmethod
      def _apply_source_filter(src: Dict[str, Any], source_spec: Any) -> Dict[str, Any]:
          if source_spec is None:
              return dict(src)
          if source_spec is False:
              return {}
          if isinstance(source_spec, dict):
              includes = source_spec.get("includes") or []
          elif isinstance(source_spec, list):
              includes = source_spec
          else:
              includes = []
          if not includes:
              return dict(src)
          return {k: v for k, v in src.items() if k in set(includes)}
  
      @staticmethod
      def _full_source(doc_id: str) -> Dict[str, Any]:
          return {
              "spu_id": doc_id,
              "title": {"en": f"product-{doc_id}"},
              "brief": {"en": f"brief-{doc_id}"},
              "vendor": {"en": f"vendor-{doc_id}"},
              "skus": [],
          }
  
a47416ec   tangwang   把融合逻辑改成乘法公式,并把 ES...
128
129
130
131
132
133
134
135
      def search(
          self,
          index_name: str,
          body: Dict[str, Any],
          size: int,
          from_: int,
          include_named_queries_score: bool = False,
      ):
5f7d7f09   tangwang   性能测试报告.md
136
          self.calls.append(
a47416ec   tangwang   把融合逻辑改成乘法公式,并把 ES...
137
138
139
140
141
142
143
              {
                  "index_name": index_name,
                  "body": body,
                  "size": size,
                  "from_": from_,
                  "include_named_queries_score": include_named_queries_score,
              }
5f7d7f09   tangwang   性能测试报告.md
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
          )
          ids_query = (((body or {}).get("query") or {}).get("ids") or {}).get("values")
          source_spec = (body or {}).get("_source")
  
          if isinstance(ids_query, list):
              # Return reversed order intentionally; caller should restore original ranking order.
              ids = [str(i) for i in ids_query][::-1]
              hits = []
              for doc_id in ids:
                  src = self._apply_source_filter(self._full_source(doc_id), source_spec)
                  hit = {"_id": doc_id, "_score": 1.0}
                  if source_spec is not False:
                      hit["_source"] = src
                  hits.append(hit)
          else:
              end = min(from_ + size, self.total_hits)
              hits = []
              for i in range(from_, end):
                  doc_id = str(i)
                  src = self._apply_source_filter(self._full_source(doc_id), source_spec)
                  hit = {"_id": doc_id, "_score": float(self.total_hits - i)}
                  if source_spec is not False:
                      hit["_source"] = src
                  hits.append(hit)
  
          return {
              "took": 8,
              "hits": {
                  "total": {"value": self.total_hits},
                  "max_score": hits[0]["_score"] if hits else 0.0,
                  "hits": hits,
              },
          }
  
  
c51d254f   tangwang   性能测试
179
  def _build_search_config(*, rerank_enabled: bool = True, rerank_window: int = 384):
5f7d7f09   tangwang   性能测试报告.md
180
181
182
183
      return SearchConfig(
          field_boosts={"title.en": 3.0},
          indexes=[IndexConfig(name="default", label="default", fields=["title.en"])],
          query_config=QueryConfig(enable_text_embedding=False, enable_query_rewrite=False),
5f7d7f09   tangwang   性能测试报告.md
184
185
186
187
          function_score=FunctionScoreConfig(),
          rerank=RerankConfig(enabled=rerank_enabled, rerank_window=rerank_window),
          spu_config=SPUConfig(enabled=False),
          es_index_name="test_products",
5f7d7f09   tangwang   性能测试报告.md
188
          es_settings={},
5f7d7f09   tangwang   性能测试报告.md
189
190
191
192
193
194
195
196
197
198
199
200
201
      )
  
  
  def _build_searcher(config: SearchConfig, es_client: _FakeESClient) -> Searcher:
      searcher = Searcher(
          es_client=es_client,
          config=config,
          query_parser=_FakeQueryParser(),
      )
      searcher.query_builder = _FakeQueryBuilder()
      return searcher
  
  
deccd68a   tangwang   Added the SKU pre...
202
203
204
205
206
207
208
209
210
211
212
213
214
  class _FakeTextEncoder:
      def __init__(self, vectors: Dict[str, List[float]]):
          self.vectors = {
              key: np.array(value, dtype=np.float32)
              for key, value in vectors.items()
          }
  
      def encode(self, sentences, priority: int = 0, **kwargs):
          if isinstance(sentences, str):
              sentences = [sentences]
          return np.array([self.vectors[text] for text in sentences], dtype=object)
  
  
5f7d7f09   tangwang   性能测试报告.md
215
216
217
218
219
220
  def test_config_loader_rerank_enabled_defaults_true(tmp_path: Path):
      config_data = {
          "es_index_name": "test_products",
          "field_boosts": {"title.en": 3.0},
          "indexes": [{"name": "default", "label": "default", "fields": ["title.en"]}],
          "query_config": {"supported_languages": ["en"], "default_language": "en"},
ef5baa86   tangwang   混杂语言处理
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
          "services": {
              "translation": {
                  "service_url": "http://localhost:6005",
                  "timeout_sec": 3.0,
                  "default_model": "dummy-model",
                  "default_scene": "general",
                  "cache": {
                      "ttl_seconds": 60,
                      "sliding_expiration": True,
                  },
                  "capabilities": {
                      "dummy-model": {
                          "enabled": True,
                          "backend": "llm",
                          "use_cache": True,
                          "model": "dummy-model",
                          "base_url": "http://localhost:6005/v1",
                          "timeout_sec": 3.0,
                      }
                  },
              },
              "embedding": {
                  "provider": "http",
                  "providers": {
                      "http": {
                          "text_base_url": "http://localhost:6005",
                          "image_base_url": "http://localhost:6008",
                      }
                  },
                  "backend": "tei",
                  "backends": {
                      "tei": {
                          "base_url": "http://localhost:8080",
                          "timeout_sec": 3.0,
                          "model_id": "dummy-embedding-model",
                      }
                  },
              },
              "rerank": {
                  "provider": "http",
                  "providers": {
                      "http": {
                          "base_url": "http://localhost:6007",
                          "service_url": "http://localhost:6007/rerank",
                      }
                  },
                  "backend": "bge",
                  "backends": {
                      "bge": {
                          "model_name": "dummy-rerank-model",
                          "device": "cpu",
                          "use_fp16": False,
                          "batch_size": 8,
                          "max_length": 128,
                          "cache_dir": "./model_cache",
                          "enable_warmup": False,
                      }
                  },
              },
          },
5f7d7f09   tangwang   性能测试报告.md
281
          "spu_config": {"enabled": False},
5f7d7f09   tangwang   性能测试报告.md
282
          "function_score": {"score_mode": "sum", "boost_mode": "multiply", "functions": []},
c51d254f   tangwang   性能测试
283
          "rerank": {"rerank_window": 384},
5f7d7f09   tangwang   性能测试报告.md
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
      }
      config_path = tmp_path / "config.yaml"
      config_path.write_text(yaml.safe_dump(config_data), encoding="utf-8")
  
      loader = ConfigLoader(config_path)
      loaded = loader.load_config(validate=False)
  
      assert loaded.rerank.enabled is True
  
  
  def test_searcher_reranks_top_window_by_default(monkeypatch):
      es_client = _FakeESClient()
      searcher = _build_searcher(_build_search_config(rerank_enabled=True), es_client)
      context = create_request_context(reqid="t1", uid="u1")
  
      monkeypatch.setattr(
          "search.searcher.get_tenant_config_loader",
          lambda: SimpleNamespace(get_tenant_config=lambda tenant_id: {"index_languages": ["en"]}),
      )
  
      called: Dict[str, Any] = {"count": 0, "docs": 0}
  
      def _fake_run_rerank(**kwargs):
          called["count"] += 1
          called["docs"] = len(kwargs["es_response"]["hits"]["hits"])
          return kwargs["es_response"], None, []
  
      monkeypatch.setattr("search.rerank_client.run_rerank", _fake_run_rerank)
  
      result = searcher.search(
          query="toy",
          tenant_id="162",
          from_=20,
          size=10,
          context=context,
          enable_rerank=None,
      )
  
      assert called["count"] == 1
77ab67ad   tangwang   更新测试用例
323
324
325
      # 应当对配置的 rerank_window 条文档做重排预取
      window = searcher.config.rerank.rerank_window
      assert called["docs"] == window
5f7d7f09   tangwang   性能测试报告.md
326
      assert es_client.calls[0]["from_"] == 0
77ab67ad   tangwang   更新测试用例
327
      assert es_client.calls[0]["size"] == window
a47416ec   tangwang   把融合逻辑改成乘法公式,并把 ES...
328
      assert es_client.calls[0]["include_named_queries_score"] is True
5f7d7f09   tangwang   性能测试报告.md
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
      assert es_client.calls[0]["body"]["_source"] == {"includes": ["title"]}
      assert len(es_client.calls) == 2
      assert es_client.calls[1]["size"] == 10
      assert es_client.calls[1]["from_"] == 0
      assert es_client.calls[1]["body"]["query"]["ids"]["values"] == [str(i) for i in range(20, 30)]
      assert len(result.results) == 10
      assert result.results[0].spu_id == "20"
      assert result.results[0].brief == "brief-20"
  
  
  def test_searcher_rerank_prefetch_source_follows_doc_template(monkeypatch):
      es_client = _FakeESClient()
      searcher = _build_searcher(_build_search_config(rerank_enabled=True), es_client)
      context = create_request_context(reqid="t1b", uid="u1b")
  
      monkeypatch.setattr(
          "search.searcher.get_tenant_config_loader",
          lambda: SimpleNamespace(get_tenant_config=lambda tenant_id: {"index_languages": ["en"]}),
      )
      monkeypatch.setattr("search.rerank_client.run_rerank", lambda **kwargs: (kwargs["es_response"], None, []))
  
      searcher.search(
          query="toy",
          tenant_id="162",
          from_=0,
          size=5,
          context=context,
          enable_rerank=None,
          rerank_doc_template="{title} {vendor} {brief}",
      )
  
      assert es_client.calls[0]["body"]["_source"] == {"includes": ["brief", "title", "vendor"]}
  
  
cda1cd62   tangwang   意图分析&应用 baseline
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
  def test_searcher_rerank_prefetch_source_includes_sku_fields_when_style_intent_active(monkeypatch):
      es_client = _FakeESClient()
      searcher = _build_searcher(_build_search_config(rerank_enabled=True), es_client)
      context = create_request_context(reqid="t1c", uid="u1c")
  
      monkeypatch.setattr(
          "search.searcher.get_tenant_config_loader",
          lambda: SimpleNamespace(get_tenant_config=lambda tenant_id: {"index_languages": ["en"]}),
      )
      monkeypatch.setattr(
          "search.rerank_client.run_rerank",
          lambda **kwargs: (kwargs["es_response"], None, []),
      )
  
      class _IntentQueryParser:
          text_encoder = None
  
          def parse(
              self,
              query: str,
              tenant_id: str,
              generate_vector: bool,
              context: Any,
              target_languages: Any = None,
          ):
              return _FakeParsedQuery(
                  original_query=query,
                  query_normalized=query,
                  rewritten_query=query,
                  translations={},
                  style_intent_profile=_build_style_intent_profile(
                      "color", "black", "color", "colors", "颜色"
                  ),
              )
  
      searcher.query_parser = _IntentQueryParser()
  
      searcher.search(
          query="black dress",
          tenant_id="162",
          from_=0,
          size=5,
          context=context,
          enable_rerank=None,
      )
  
      assert es_client.calls[0]["body"]["_source"] == {
          "includes": ["option1_name", "option2_name", "option3_name", "skus", "title"]
      }
  
  
5f7d7f09   tangwang   性能测试报告.md
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
  def test_searcher_skips_rerank_when_request_explicitly_false(monkeypatch):
      es_client = _FakeESClient()
      searcher = _build_searcher(_build_search_config(rerank_enabled=True), es_client)
      context = create_request_context(reqid="t2", uid="u2")
  
      monkeypatch.setattr(
          "search.searcher.get_tenant_config_loader",
          lambda: SimpleNamespace(get_tenant_config=lambda tenant_id: {"index_languages": ["en"]}),
      )
  
      called: Dict[str, int] = {"count": 0}
  
      def _fake_run_rerank(**kwargs):
          called["count"] += 1
          return kwargs["es_response"], None, []
  
      monkeypatch.setattr("search.rerank_client.run_rerank", _fake_run_rerank)
  
      searcher.search(
          query="toy",
          tenant_id="162",
          from_=20,
          size=10,
          context=context,
          enable_rerank=False,
      )
  
      assert called["count"] == 0
      assert es_client.calls[0]["from_"] == 20
      assert es_client.calls[0]["size"] == 10
a47416ec   tangwang   把融合逻辑改成乘法公式,并把 ES...
444
      assert es_client.calls[0]["include_named_queries_score"] is False
5f7d7f09   tangwang   性能测试报告.md
445
446
447
448
449
      assert len(es_client.calls) == 1
  
  
  def test_searcher_skips_rerank_when_page_exceeds_window(monkeypatch):
      es_client = _FakeESClient()
c51d254f   tangwang   性能测试
450
      searcher = _build_searcher(_build_search_config(rerank_enabled=True, rerank_window=384), es_client)
5f7d7f09   tangwang   性能测试报告.md
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
      context = create_request_context(reqid="t3", uid="u3")
  
      monkeypatch.setattr(
          "search.searcher.get_tenant_config_loader",
          lambda: SimpleNamespace(get_tenant_config=lambda tenant_id: {"index_languages": ["en"]}),
      )
  
      called: Dict[str, int] = {"count": 0}
  
      def _fake_run_rerank(**kwargs):
          called["count"] += 1
          return kwargs["es_response"], None, []
  
      monkeypatch.setattr("search.rerank_client.run_rerank", _fake_run_rerank)
  
      searcher.search(
          query="toy",
          tenant_id="162",
          from_=995,
          size=10,
          context=context,
          enable_rerank=None,
      )
  
      assert called["count"] == 0
      assert es_client.calls[0]["from_"] == 995
      assert es_client.calls[0]["size"] == 10
a47416ec   tangwang   把融合逻辑改成乘法公式,并把 ES...
478
      assert es_client.calls[0]["include_named_queries_score"] is False
5f7d7f09   tangwang   性能测试报告.md
479
      assert len(es_client.calls) == 1
deccd68a   tangwang   Added the SKU pre...
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
  
  
  def test_searcher_promotes_sku_when_option1_matches_translated_query(monkeypatch):
      es_client = _FakeESClient(total_hits=1)
      searcher = _build_searcher(_build_search_config(rerank_enabled=False), es_client)
      context = create_request_context(reqid="sku-text", uid="u-sku-text")
  
      monkeypatch.setattr(
          "search.searcher.get_tenant_config_loader",
          lambda: SimpleNamespace(get_tenant_config=lambda tenant_id: {"index_languages": ["en", "zh"]}),
      )
  
      class _TranslatedQueryParser:
          text_encoder = None
  
ef5baa86   tangwang   混杂语言处理
495
496
497
498
499
500
501
502
          def parse(
              self,
              query: str,
              tenant_id: str,
              generate_vector: bool,
              context: Any,
              target_languages: Any = None,
          ):
deccd68a   tangwang   Added the SKU pre...
503
504
505
506
507
              return _FakeParsedQuery(
                  original_query=query,
                  query_normalized=query,
                  rewritten_query=query,
                  translations={"en": "black dress"},
cda1cd62   tangwang   意图分析&应用 baseline
508
509
510
                  style_intent_profile=_build_style_intent_profile(
                      "color", "black", "color", "colors", "颜色"
                  ),
deccd68a   tangwang   Added the SKU pre...
511
512
513
514
515
516
517
518
519
520
              )
  
      searcher.query_parser = _TranslatedQueryParser()
  
      def _full_source_with_skus(doc_id: str) -> Dict[str, Any]:
          return {
              "spu_id": doc_id,
              "title": {"en": f"product-{doc_id}"},
              "brief": {"en": f"brief-{doc_id}"},
              "vendor": {"en": f"vendor-{doc_id}"},
a7cc9078   tangwang   sku排序
521
              "option1_name": "Color",
deccd68a   tangwang   Added the SKU pre...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
              "image_url": "https://img/default.jpg",
              "skus": [
                  {"sku_id": "sku-red", "option1_value": "Red", "image_src": "https://img/red.jpg"},
                  {"sku_id": "sku-black", "option1_value": "Black", "image_src": "https://img/black.jpg"},
              ],
          }
  
      monkeypatch.setattr(_FakeESClient, "_full_source", staticmethod(_full_source_with_skus))
  
      result = searcher.search(
          query="黑色 连衣裙",
          tenant_id="162",
          from_=0,
          size=1,
          context=context,
          enable_rerank=False,
      )
  
      assert len(result.results) == 1
      assert result.results[0].skus[0].sku_id == "sku-black"
      assert result.results[0].image_url == "https://img/black.jpg"
  
  
  def test_searcher_promotes_sku_by_embedding_when_query_has_no_direct_option_match(monkeypatch):
      es_client = _FakeESClient(total_hits=1)
      searcher = _build_searcher(_build_search_config(rerank_enabled=False), es_client)
      context = create_request_context(reqid="sku-embed", uid="u-sku-embed")
  
      monkeypatch.setattr(
          "search.searcher.get_tenant_config_loader",
          lambda: SimpleNamespace(get_tenant_config=lambda tenant_id: {"index_languages": ["en"]}),
      )
  
      encoder = _FakeTextEncoder(
          {
              "linen summer dress": [0.8, 0.2],
cda1cd62   tangwang   意图分析&应用 baseline
558
559
              "red": [1.0, 0.0],
              "blue": [0.0, 1.0],
deccd68a   tangwang   Added the SKU pre...
560
561
562
563
564
565
          }
      )
  
      class _EmbeddingQueryParser:
          text_encoder = encoder
  
ef5baa86   tangwang   混杂语言处理
566
567
568
569
570
571
572
573
          def parse(
              self,
              query: str,
              tenant_id: str,
              generate_vector: bool,
              context: Any,
              target_languages: Any = None,
          ):
deccd68a   tangwang   Added the SKU pre...
574
575
576
577
578
579
              return _FakeParsedQuery(
                  original_query=query,
                  query_normalized=query,
                  rewritten_query=query,
                  translations={},
                  query_vector=np.array([0.0, 1.0], dtype=np.float32),
cda1cd62   tangwang   意图分析&应用 baseline
580
581
582
                  style_intent_profile=_build_style_intent_profile(
                      "color", "blue", "color", "colors", "颜色"
                  ),
deccd68a   tangwang   Added the SKU pre...
583
584
585
586
587
588
589
590
591
592
              )
  
      searcher.query_parser = _EmbeddingQueryParser()
  
      def _full_source_with_skus(doc_id: str) -> Dict[str, Any]:
          return {
              "spu_id": doc_id,
              "title": {"en": f"product-{doc_id}"},
              "brief": {"en": f"brief-{doc_id}"},
              "vendor": {"en": f"vendor-{doc_id}"},
a7cc9078   tangwang   sku排序
593
              "option1_name": "Color",
deccd68a   tangwang   Added the SKU pre...
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
              "image_url": "https://img/default.jpg",
              "skus": [
                  {"sku_id": "sku-red", "option1_value": "Red", "image_src": "https://img/red.jpg"},
                  {"sku_id": "sku-blue", "option1_value": "Blue", "image_src": "https://img/blue.jpg"},
              ],
          }
  
      monkeypatch.setattr(_FakeESClient, "_full_source", staticmethod(_full_source_with_skus))
  
      result = searcher.search(
          query="linen summer dress",
          tenant_id="162",
          from_=0,
          size=1,
          context=context,
          enable_rerank=False,
      )
  
      assert len(result.results) == 1
      assert result.results[0].skus[0].sku_id == "sku-blue"
      assert result.results[0].image_url == "https://img/blue.jpg"