Commit 518578dc authored by Sandro Knauß's avatar Sandro Knauß
Browse files

Fix 370385: Search for contacts with underscore.

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

FIXES: 370385
FIXED-IN: 5.17.0
parent 4f1d84cf
......@@ -54,7 +54,6 @@ private:
qDebug() << "result:" << result << "(in" << t.elapsed() << "ms)";
QEXPECT_FAIL("contact by name (oe)", "Does not work for the moment", Continue);
QEXPECT_FAIL("search extras in subject", "Does not work for the moment", Continue);
QEXPECT_FAIL("contact by email (jack_sparrow@test.com)", "We split terms by underscore manually (testcase for #370385).", Continue);
QCOMPARE(result, expectedResult);
}
......
......@@ -72,8 +72,8 @@ QStringList XapianTermGenerator::termList(const QString &text)
void XapianTermGenerator::indexText(const QString &text, const QString &prefix, int wdfInc)
{
const QByteArray par = prefix.toUtf8();
// const QByteArray ta = text.toUtf8();
// m_termGen.index_text(ta.constData(), wdfInc, par.constData());
const QByteArray ta = text.toUtf8();
m_termGen.index_text(ta.constData(), wdfInc, par.constData());
const QStringList terms = termList(text);
for (const QString &term : terms) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment