mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-05 11:07:55 -05:00
fix: note search shows no excerpt when the match is deep inside a note (#35561)
Searching Notes for words that appear far into a note listed the note but showed no excerpt next to its title, because the search results only carried the start of each note. The results now carry the part of the note around the first match instead, and each result stays as small as before, so the words around the match show up wherever they are in the note. While searching, the grid preview of such a note starts near the match too. Matches near the start and matches only in the title look the same as before. Fixes #35556
This commit is contained in:
1 parent
e160769e2f
commit
2026de4bcb
1 file changed
+5
-1
@@ -69,8 +69,12 @@ def truncate_note_data(data: Optional[dict], max_length: int = 1000, query: str
|
||||
return data
|
||||
page = matching_page(data, query)
|
||||
md = page['content'].get('md') or ''
|
||||
text = md.lower()
|
||||
hits = [text.find(term) for term in query.lower().split() if term in text]
|
||||
# Start a little before the first search hit so the list can show the words around it.
|
||||
start = max(0, min(hits) - 100) if hits else 0
|
||||
return {
|
||||
'content': {'md': md[:max_length]},
|
||||
'content': {'md': md[start : start + max_length]},
|
||||
'page_count': len(data.get('pages') or [None]),
|
||||
'page_id': page['id'],
|
||||
'page_title': page['title'],
|
||||
|
||||
Reference in new issue
Block a user