Add caption-only lexical retrieval to Meilisearch client

This commit is contained in:
Sleeps
2026-10-08 10:30:16 +01:00
parent 55748064ac
commit 262cec6fec
+26
View File
@@ -144,6 +144,32 @@ class Meili:
self.session.get(f"{self.url}/indexes/{self.index}/stats")
).json()
def search_caption_text(
self,
query: str,
limit: int = 20,
filter_expression: str | None = None,
) -> dict:
"""Find literal caption matches without visual-vector dilution.
The field restriction prevents title and tag matches from masquerading
as caption hits. Requiring all terms avoids loose one-word matches
displacing ordinary Jellyfin search results.
"""
payload = {
"q": query,
"limit": limit,
"attributesToSearchOn": ["caption"],
"matchingStrategy": "all",
"showRankingScore": True,
}
if filter_expression:
payload["filter"] = filter_expression
return self._check(self.session.post(
f"{self.url}/indexes/{self.index}/search",
json=payload,
)).json()
def search_vector(
self,
vector: Iterable[float],