summaryrefslogtreecommitdiffstats
path: root/searchcommon
diff options
context:
space:
mode:
Diffstat (limited to 'searchcommon')
-rw-r--r--searchcommon/src/vespa/searchcommon/attribute/i_search_context.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
index aa1ddb2f3d1..151e24b5b64 100644
--- a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
+++ b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h
@@ -53,7 +53,15 @@ public:
int32_t find(DocId docId, int32_t elementId, int32_t &weight) const { return onCmp(docId, elementId, weight); }
int32_t find(DocId docId, int32_t elementId) const { return onCmp(docId, elementId); }
- bool matches(DocId docId, int32_t &weight) const { return find(docId, 0, weight) >= 0; }
+ bool matches(DocId docId, int32_t &weight) const {
+ weight = 0;
+ int32_t oneWeight(0);
+ int32_t firstId = find(docId, 0, oneWeight);
+ for (int32_t id(firstId); id >= 0; id = find(docId, id + 1, oneWeight)) {
+ weight += oneWeight;
+ }
+ return firstId >= 0;
+ }
bool matches(DocId doc) const { return find(doc, 0) >= 0; }
};