summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2019-10-04 09:40:55 +0000
committerHåvard Pettersen <havardpe@oath.com>2019-10-04 09:40:55 +0000
commit993e29c9e59c26616bfd966a6ec94008d5589516 (patch)
treebdfe141231f7e1d562028de92f1ef77e6188d2cd /searchcore
parent4f8280c6285adafd95a8059f7440b25aa6494ac0 (diff)
find matching elements for attribute terms searching in struct subfields
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp
index 34310371755..71b1164d127 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/docsum_matcher.cpp
@@ -4,6 +4,7 @@
#include <vespa/eval/eval/tensor.h>
#include <vespa/eval/eval/tensor_engine.h>
#include <vespa/vespalib/objects/nbostream.h>
+#include <vespa/searchcommon/attribute/i_search_context.h>
#include <vespa/searchlib/queryeval/blueprint.h>
#include <vespa/searchlib/queryeval/intermediate_blueprints.h>
#include <vespa/searchlib/queryeval/same_element_blueprint.h>
@@ -23,6 +24,8 @@ using search::queryeval::IntermediateBlueprint;
using search::queryeval::SameElementBlueprint;
using search::queryeval::SearchIterator;
+using AttrSearchCtx = search::attribute::ISearchContext;
+
namespace proton::matching {
namespace {
@@ -98,11 +101,29 @@ void find_matching_elements(const std::vector<uint32_t> &docs, const SameElement
}
}
+void find_matching_elements(const std::vector<uint32_t> &docs, const vespalib::string &struct_field_name, const AttrSearchCtx &attr_ctx, MatchingElements &result) {
+ int32_t weight = 0;
+ std::vector<uint32_t> matches;
+ for (uint32_t i = 0; i < docs.size(); ++i) {
+ for (int32_t id = attr_ctx.find(docs[i], 0, weight); id >= 0; id = attr_ctx.find(docs[i], id+1, weight)) {
+ matches.push_back(id);
+ }
+ if (!matches.empty()) {
+ result.add_matching_elements(docs[i], struct_field_name, matches);
+ matches.clear();
+ }
+ }
+}
+
void find_matching_elements(const StructFieldMapper &mapper, const std::vector<uint32_t> &docs, const Blueprint &bp, MatchingElements &result) {
if (auto same_element = as<SameElementBlueprint>(bp)) {
if (mapper.is_struct_field(same_element->struct_field_name())) {
find_matching_elements(docs, *same_element, result);
}
+ } else if (const AttrSearchCtx *attr_ctx = bp.get_attribute_search_context()) {
+ if (mapper.is_struct_subfield(attr_ctx->attributeName())) {
+ find_matching_elements(docs, mapper.get_struct_field(attr_ctx->attributeName()), *attr_ctx, result);
+ }
} else if (auto and_not = as<AndNotBlueprint>(bp)) {
find_matching_elements(mapper, docs, and_not->getChild(0), result);
} else if (auto intermediate = as<IntermediateBlueprint>(bp)) {