Skip to content

Fix 370385: Search for contacts with underscore.

Sandro Knauß requested to merge work/hefee/search_underscore into master

Currently we do word split by underscore. Th result is, that we cannot search for anything with a underscore. To fix this we need to add more words to the term list where also the term with underscore is added. I search in the history of baloo: This handmade term splitter was added to search for files with underscores (#336034).

So we need either get control over the term splitting, while searching, or add the term with underscore to terms list. When we want to provide both (splitted and non-splitted) we also need to take care about the position parameter.

Without patching xapiantermgenerator we can sill search for the complete email address on the commandline:

cd /tmp/searchplugintest/contacts
$ xapian-delve -t blue -d .
Posting List for term 'blue' (termfreq 1, collfreq 1, wdf_max 1): 101 []
$ xapian-delve -t jack_blue@test.com -d .
Posting List for term 'jack_blue@test.com' (termfreq 1, collfreq 1,
wdf_max 1): 101 []

but NOT:

$ xapian-delve -t jack_blue -d .
term 'jack_blue' not in database

The current solution makes the termgeneratortest fail, because we created more words, but fixes search for underscore value.

********* Start testing of TermGeneratorTest *********
Config: Using QtTest library 5.15.2, Qt 5.15.2
(x86_64-little_endian-lp64 shared (dynamic) release build; by GCC
9.3.0), neon 20.04
PASS   : TermGeneratorTest::initTestCase()
PASS   : TermGeneratorTest::testWordBoundaries()
FAIL!  : TermGeneratorTest::testUnderscore_splitting() Compared lists
have different sizes.
   Actual   (words) size: 3
   Expected (expectedWords) size: 2
   Loc:
[/home/neon/kdepim/src/kde/pim/akonadi-search/xapian/autotests/termgeneratortest.cpp(62)]
FAIL!  : TermGeneratorTest::testAccetCharacters() Compared lists have
different sizes.
   Actual   (words) size: 5
   Expected (expectedWords) size: 3
   Loc:
[/home/neon/kdepim/src/kde/pim/akonadi-search/xapian/autotests/termgeneratortest.cpp(78)]
FAIL!  : TermGeneratorTest::testUnicodeCompatibleComposition() Compared
values are not the same
   Actual   (words.size()): 2
   Expected (1)           : 1
   Loc:
[/home/neon/kdepim/src/kde/pim/akonadi-search/xapian/autotests/termgeneratortest.cpp(92)]
PASS   : TermGeneratorTest::testEmails()
PASS   : TermGeneratorTest::testWordPositions()
PASS   : TermGeneratorTest::cleanupTestCase()
Totals: 5 passed, 3 failed, 0 skipped, 0 blacklisted, 44ms
********* Finished testing of TermGeneratorTest *********

FIXES: 370385

FIXED-IN: 5.17.0

Merge request reports