When doing FTS on notes also match on item values

This commit is contained in:
Kovid Goyal 2023-09-05 09:03:32 +05:30
parent 00936dbafb
commit 54c43bc7ef
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 0 deletions

View File

@ -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:

View File

@ -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