summaryrefslogtreecommitdiffstats
path: root/searchcommon
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-05-23 18:21:01 +0200
committerHenning Baldersheim <balder@oath.com>2018-05-23 23:21:04 +0200
commitfad8b5a92af2c3bc5749f8196f8f1f954b0d7171 (patch)
tree352fc9fbe1b16a12a82af0c7f4a14b94105151b0 /searchcommon
parentec25fafaa3b922c688113bdefac2d12feb9fdca8 (diff)
Only return the weight of the first match. Accumulate on the outside.
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; }
};