From 54c43bc7ef74dd4cf3521649f89d6e6f9d439131 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Sep 2023 09:03:32 +0530 Subject: [PATCH] When doing FTS on notes also match on item values --- src/calibre/db/notes/connect.py | 1 + src/calibre/db/tests/notes.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/calibre/db/notes/connect.py b/src/calibre/db/notes/connect.py index ad001252f8..ce5241ad73 100644 --- a/src/calibre/db/notes/connect.py +++ b/src/calibre/db/notes/connect.py @@ -200,6 +200,7 @@ class Notes: def set_note(self, conn, field_name, item_id, item_value, marked_up_text='', used_resource_hashes=(), searchable_text=copy_marked_up_text): if searchable_text is copy_marked_up_text: searchable_text = marked_up_text + searchable_text = item_value + '\n' + searchable_text note_id = self.note_id_for(conn, field_name, item_id) old_resources = frozenset(self.resources_used_by(conn, note_id)) if not marked_up_text: diff --git a/src/calibre/db/tests/notes.py b/src/calibre/db/tests/notes.py index 460c8d08fd..132d992ade 100644 --- a/src/calibre/db/tests/notes.py +++ b/src/calibre/db/tests/notes.py @@ -120,6 +120,11 @@ def test_fts(self: 'NotesTest'): self.ae(ids_for_search('common'), {('authors', authors[0]), ('authors', authors[1]), ('tags', tags[0]), ('tags', tags[1])}) self.ae(ids_for_search('common', ('tags',)), {('tags', tags[0]), ('tags', tags[1])}) + # test that searching by item value works + an = cache.get_item_name('authors', authors[0]) + self.ae(ids_for_search(' AND '.join(an.split()), ('authors',)), {('authors', authors[0])}) + + class NotesTest(BaseTest): ae = BaseTest.assertEqual