mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-19 00:03:36 +00:00
Use Meilisearch PUT for partial caption metadata updates
This commit is contained in:
+20
-4
@@ -68,14 +68,25 @@ class Meili:
|
||||
f"{self.url}/indexes/{self.index}/documents",
|
||||
))
|
||||
|
||||
def add_documents(self, documents: list[dict]) -> None:
|
||||
def add_documents(
|
||||
self,
|
||||
documents: list[dict],
|
||||
*,
|
||||
wait: bool = False,
|
||||
) -> None:
|
||||
"""Replace complete documents (used for indexing and targeted repairs)."""
|
||||
if not documents:
|
||||
return
|
||||
self._check(self.session.post(
|
||||
response = self._check(self.session.post(
|
||||
f"{self.url}/indexes/{self.index}/documents",
|
||||
params={"primaryKey": "id"},
|
||||
json=documents,
|
||||
))
|
||||
if wait:
|
||||
task_uid = response.json().get("taskUid")
|
||||
if task_uid is None:
|
||||
raise RuntimeError("Meilisearch replacement did not return a taskUid")
|
||||
self.wait_for_task(int(task_uid))
|
||||
|
||||
def wait_for_task(self, task_uid: int, *, timeout_seconds: float = 120) -> dict:
|
||||
deadline = time.monotonic() + timeout_seconds
|
||||
@@ -105,12 +116,17 @@ class Meili:
|
||||
*,
|
||||
wait: bool = False,
|
||||
) -> None:
|
||||
"""Partially update existing documents without replacing omitted fields."""
|
||||
"""Update only supplied caption fields, preserving identities and vectors.
|
||||
|
||||
POST replaces an entire Meilisearch document; PUT is the partial-update
|
||||
endpoint. Using POST here previously deleted titles, Jellyfin item IDs,
|
||||
and SigLIP vectors whenever a caption was synchronised.
|
||||
"""
|
||||
if not documents:
|
||||
return
|
||||
self.ensure_index()
|
||||
response = self._check(
|
||||
self.session.post(
|
||||
self.session.put(
|
||||
f"{self.url}/indexes/{self.index}/documents",
|
||||
params={"primaryKey": "id"},
|
||||
json=documents,
|
||||
|
||||
Reference in New Issue
Block a user