diff options
Diffstat (limited to 'streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp')
-rw-r--r-- | streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp b/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp index c75ab7fccd3..72807bc6c34 100644 --- a/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp +++ b/streamingvisitors/src/vespa/vsm/searcher/fieldsearcher.cpp @@ -3,7 +3,7 @@ #include <vespa/vsm/vsm/fieldsearchspec.h> #include <vespa/document/fieldvalue/arrayfieldvalue.h> #include <vespa/document/fieldvalue/weightedsetfieldvalue.h> -#include <vespa/searchlib/query/streaming/multi_term.h> +#include <vespa/searchlib/query/streaming/equiv_query_node.h> #include <vespa/vespalib/stllike/hash_set.h> #include <cassert> @@ -190,6 +190,39 @@ FieldSearcher::init() } void +FieldIdTSearcherMap::prepare_term(const DocumentTypeIndexFieldMapT& difm, QueryTerm* qt, FieldIdT fid, vespalib::hash_set<const void*>& seen, QueryTermList& onlyInIndex) +{ + auto equiv = qt->as_equiv_query_node(); + if (equiv != nullptr) { + for (auto& subterm : equiv->get_terms()) { + prepare_term(difm, subterm.get(), fid, seen, onlyInIndex); + } + return; + } + for (const auto& doc_type_elem : difm) { + const IndexFieldMapT & fim = doc_type_elem.second; + auto found = fim.find(FieldSearchSpecMap::stripNonFields(qt->index())); + if (found != fim.end()) { + const FieldIdTList & index = found->second; + if ((find(index.begin(), index.end(), fid) != index.end()) && !seen.contains(qt)) { + seen.insert(qt); + auto multi_term = qt->as_multi_term(); + if (multi_term != nullptr) { + for (auto& subterm : multi_term->get_terms()) { + onlyInIndex.emplace_back(subterm.get()); + } + } else { + onlyInIndex.emplace_back(qt); + } + } + } else { + LOG(debug, "Could not find the requested index=%s in the index config map. Query does not fit search definition.", + qt->index().c_str()); + } + } +} + +void FieldIdTSearcherMap::prepare(const DocumentTypeIndexFieldMapT& difm, const SharedSearcherBuf& searcherBuf, Query& query, const vsm::FieldPathMapT& field_paths, search::fef::IQueryEnvironment& query_env) @@ -202,27 +235,7 @@ FieldIdTSearcherMap::prepare(const DocumentTypeIndexFieldMapT& difm, const Share vespalib::hash_set<const void*> seen; FieldIdT fid = searcher->field(); for (auto qt : qtl) { - for (const auto& doc_type_elem : difm) { - const IndexFieldMapT & fim = doc_type_elem.second; - auto found = fim.find(FieldSearchSpecMap::stripNonFields(qt->index())); - if (found != fim.end()) { - const FieldIdTList & index = found->second; - if ((find(index.begin(), index.end(), fid) != index.end()) && !seen.contains(qt)) { - seen.insert(qt); - auto multi_term = qt->as_multi_term(); - if (multi_term != nullptr) { - for (auto& subterm : multi_term->get_terms()) { - onlyInIndex.emplace_back(subterm.get()); - } - } else { - onlyInIndex.emplace_back(qt); - } - } - } else { - LOG(debug, "Could not find the requested index=%s in the index config map. Query does not fit search definition.", - qt->index().c_str()); - } - } + prepare_term(difm, qt, fid, seen, onlyInIndex); } /// Should perhaps do a unique on onlyInIndex searcher->prepare(onlyInIndex, searcherBuf, field_paths, query_env); |