Compare commits

...

3 Commits

Author SHA1 Message Date
Trenton H
45906884f3 Merge branch 'dev' into fix-search-minor-things 2026-04-03 15:54:53 -07:00
Trenton H
d2f866a532 Merge branch 'dev' into fix-search-minor-things 2026-04-03 15:34:58 -07:00
Trenton Holmes
469069b401 Don't create a new note highlight generator per note in the loop 2026-04-03 14:36:42 -07:00

View File

@@ -532,6 +532,7 @@ class TantivyBackend:
# Build result hits with highlights # Build result hits with highlights
hits: list[SearchHit] = [] hits: list[SearchHit] = []
snippet_generator = None snippet_generator = None
notes_snippet_generator = None
for rank, (doc_address, score) in enumerate(page_hits, start=offset + 1): for rank, (doc_address, score) in enumerate(page_hits, start=offset + 1):
# Get the actual document from the searcher using the doc address # Get the actual document from the searcher using the doc address
@@ -558,13 +559,16 @@ class TantivyBackend:
# Try notes highlights # Try notes highlights
if "notes" in doc_dict: if "notes" in doc_dict:
notes_generator = tantivy.SnippetGenerator.create( if notes_snippet_generator is None:
searcher, notes_snippet_generator = tantivy.SnippetGenerator.create(
final_query, searcher,
self._schema, final_query,
"notes", self._schema,
"notes",
)
notes_snippet = notes_snippet_generator.snippet_from_doc(
actual_doc,
) )
notes_snippet = notes_generator.snippet_from_doc(actual_doc)
if notes_snippet: if notes_snippet:
highlights["notes"] = str(notes_snippet) highlights["notes"] = str(notes_snippet)