opensolr-haystack 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opensolr-haystack
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Haystack integration for Opensolr — managed Apache Solr DocumentStore with server-side embeddings and hybrid BM25+kNN retrieval
5
5
  Author-email: Opensolr <support@opensolr.com>
6
6
  License: MIT
@@ -309,7 +309,15 @@ class OpensolrClient:
309
309
  docs: Optional[int] = None,
310
310
  words: Optional[int] = None,
311
311
  ) -> str:
312
- """Build the LLM context from the top hybrid search hits."""
312
+ """Build the LLM context from the top hybrid search hits.
313
+
314
+ Retrieval runs through the server-side ``embed_and_search`` pipeline —
315
+ the platform's own tuned hybrid ranking (field weights, minimum-match,
316
+ quality boosts), the same machinery behind the hosted search UI, so it
317
+ improves automatically with the platform. When a custom ``fq`` is
318
+ given (which that endpoint doesn't accept) — or if it fails —
319
+ retrieval falls back to the client-side ``{!hybrid}`` query.
320
+ """
313
321
 
314
322
  def _flat(v: Any) -> str:
315
323
  if isinstance(v, list):
@@ -318,11 +326,21 @@ class OpensolrClient:
318
326
 
319
327
  docs = docs or self.RAG_DOCS
320
328
  words = words or self.RAG_WORDS
321
- body = self.hybrid_search(
322
- index, query, rows=docs, fl="title,description,text", fq=fq
323
- )
329
+ hits: List[Dict[str, Any]] = []
330
+ if not fq:
331
+ try:
332
+ body = self.embed_and_search(index, query, rows=docs)
333
+ if isinstance(body, dict):
334
+ hits = body.get("results", {}).get("docs", []) or []
335
+ except (OpensolrError, httpx.HTTPError):
336
+ hits = []
337
+ if not hits:
338
+ body = self.hybrid_search(
339
+ index, query, rows=docs, fl="title,description,text", fq=fq
340
+ )
341
+ hits = body.get("response", {}).get("docs", [])
324
342
  parts: List[str] = []
325
- for doc in body.get("response", {}).get("docs", []):
343
+ for doc in hits[:docs]:
326
344
  text_words = _flat(doc.get("text")).split()[:words]
327
345
  parts.append(
328
346
  _flat(doc.get("title")) + " - "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opensolr-haystack
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Haystack integration for Opensolr — managed Apache Solr DocumentStore with server-side embeddings and hybrid BM25+kNN retrieval
5
5
  Author-email: Opensolr <support@opensolr.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "opensolr-haystack"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  description = "Haystack integration for Opensolr — managed Apache Solr DocumentStore with server-side embeddings and hybrid BM25+kNN retrieval"
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }