[AdvancedQueryParser] Introduce support for phrase queries
Needs ReviewPublic

Authored by poboiko on Jun 30 2019, 3:38 PM.

Details

Reviewers
ngraham
bruns
Group Reviewers
Baloo
Summary

AdvancedQueryParser's lexxer can actually handle double quotes:
for query a "b c" d, it returns three tokens (a, b c, d).
However, when building Term, all of them end up having Auto comparator,
which for strings then resolves to Contains.
Finally, inside SearchStore::constructContainsQuery, we simply split such
multi-word term and build an EngineQuery::StartsWith query for b and c.

This patch sets Equal comparator for those terms that are inside double quotes.
For that we call SearchStore::constructEqualsQuery, which treats it as
EngineQuery::Phrase, which is precicely what we want.

Code-wise, it's more convenient to create a separate class Token (instead of
treating tokens as QString), which is aware if this token is inside double quotes.
This patch also moves some of the token-processing routine inside this class
(see toVariant, toComp, toOp methods)

Also, introduce various tests with double-quoted queries.

Test Plan
$ ctest
$ echo "some unique phrase" > ~/test
$ baloosearch '"some unique phrase"'

(only ~/test should pop up)

Diff Detail

Repository
R293 Baloo
Branch
phrasesearch
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 13426
Build 13444: arc lint + arc unit
poboiko created this revision.Jun 30 2019, 3:38 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptJun 30 2019, 3:38 PM
poboiko requested review of this revision.Jun 30 2019, 3:38 PM

Note that it somewhat duplicates work done inside QueryParser. Which is almost not used anywhere - most of the parsing is done by AdvancedQueryParser.

I feel somewhat weird having two separate parsers, as well as two different entities which store parsed query - i.e. EngineQuery and Term.
Do we really need them both?