diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-01-03 10:03:12 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-01-05 08:29:15 +0000 |
commit | 192af4443cb572791c8f11520e8ebec4ee4e5a8e (patch) | |
tree | 755a603c0fe1b28116a24749f4f919ffee756c84 /streamingvisitors/src/tests | |
parent | d8b50e4eaea708fed984c7c6ccdd06ac48b358bf (diff) |
- Fold query for streaming search based on either query item type, or field definition.
- This ensures that query processing and document processing is symmetric for streaming search.
No longer rely on java query processing being symmetric with backend c++ variant.
- Indexed search does no normalization in backend and uses query as is.
Diffstat (limited to 'streamingvisitors/src/tests')
-rw-r--r-- | streamingvisitors/src/tests/searcher/searcher_test.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/streamingvisitors/src/tests/searcher/searcher_test.cpp b/streamingvisitors/src/tests/searcher/searcher_test.cpp index 1ce285c2103..83b84fffa11 100644 --- a/streamingvisitors/src/tests/searcher/searcher_test.cpp +++ b/streamingvisitors/src/tests/searcher/searcher_test.cpp @@ -21,6 +21,7 @@ using namespace document; using search::streaming::HitList; using search::streaming::QueryNodeResultFactory; using search::streaming::QueryTerm; +using search::streaming::Normalizing; using search::streaming::QueryTermList; using TermType = QueryTerm::Type; using namespace vsm; @@ -56,11 +57,11 @@ public: class Query { private: - void setupQuery(const StringList & terms) { + void setupQuery(const StringList & terms, Normalizing normalizing) { for (const auto & term : terms) { ParsedQueryTerm pqt = parseQueryTerm(term); ParsedTerm pt = parseTerm(pqt.second); - qtv.push_back(std::make_unique<QueryTerm>(eqnr.create(), pt.first, pqt.first.empty() ? "index" : pqt.first, pt.second)); + qtv.push_back(std::make_unique<QueryTerm>(eqnr.create(), pt.first, pqt.first.empty() ? "index" : pqt.first, pt.second, normalizing)); } for (const auto & i : qtv) { qtl.push_back(i.get()); @@ -72,7 +73,9 @@ public: QueryNodeResultFactory eqnr; std::vector<QueryTerm::UP> qtv; QueryTermList qtl; - explicit Query(const StringList & terms); + + explicit Query(const StringList & terms) : Query(terms, Normalizing::LOWERCASE_AND_FOLD) {} + Query(const StringList & terms, Normalizing normalizing); ~Query(); static ParsedQueryTerm parseQueryTerm(const std::string & queryTerm) { size_t i = queryTerm.find(':'); @@ -94,8 +97,8 @@ public: } }; -Query::Query(const StringList & terms) : eqnr(), qtv(), qtl() { - setupQuery(terms); +Query::Query(const StringList & terms, Normalizing normalizing) : eqnr(), qtv(), qtl() { + setupQuery(terms, normalizing); } Query::~Query() = default; @@ -286,8 +289,8 @@ bool assertMatchTermSuffix(const std::string & term, const std::string & word) { QueryNodeResultFactory eqnr; - QueryTerm qa(eqnr.create(), term, "index", TermType::WORD); - QueryTerm qb(eqnr.create(), word, "index", TermType::WORD); + QueryTerm qa(eqnr.create(), term, "index", TermType::WORD, Normalizing::LOWERCASE_AND_FOLD); + QueryTerm qb(eqnr.create(), word, "index", TermType::WORD, Normalizing::LOWERCASE_AND_FOLD); const ucs4_t * a; size_t alen = qa.term(a); const ucs4_t * b; @@ -308,7 +311,7 @@ assertNumeric(FieldSearcher & fs, const StringList & query, const FieldValue & f std::vector<QueryTerm::UP> performSearch(FieldSearcher & fs, const StringList & query, const FieldValue & fv) { - Query q(query); + Query q(query, fs.exact() ? Normalizing::LOWERCASE : Normalizing::LOWERCASE_AND_FOLD); // prepare field searcher test::MockFieldSearcherEnv env; |