D22166: [AdvancedQueryParser] Introduce support for phrase queries

Igor Poboiko noreply at phabricator.kde.org
Sun Jun 30 16:38:08 BST 2019


poboiko created this revision.
poboiko added reviewers: Baloo, ngraham, bruns.
Herald added projects: Frameworks, Baloo.
poboiko requested review of this revision.

REVISION 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)

REPOSITORY
  R293 Baloo

BRANCH
  phrasesearch

REVISION DETAIL
  https://phabricator.kde.org/D22166

AFFECTED FILES
  autotests/unit/lib/advancedqueryparsertest.cpp
  src/lib/advancedqueryparser.cpp

To: poboiko, #baloo, ngraham, bruns
Cc: kde-frameworks-devel, LeGast00n, fbampaloukas, domson, ashaposhnikov, michaelh, astippich, spoorun, ngraham, bruns, abrahams
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20190630/936ef919/attachment.html>


More information about the Kde-frameworks-devel mailing list