summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2020-07-10 16:14:39 +0200
committerGitHub <noreply@github.com>2020-07-10 16:14:39 +0200
commite18537baf062b631839d6358dc5f3b2a8a5c97d7 (patch)
tree12983ad1b331283b1ce85698a7fa326f1192f3ef
parente9656bd66a67c38add039e7feccbd1fbc39614fb (diff)
parent91fd1e036739b4961f8b2e13a03974bf48e00d50 (diff)
Merge pull request #13864 from vespa-engine/geirst/support-matched-elems-only-in-streaming-search
Support matched-elements-only for array and wset fields in streaming …
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolver.java13
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java4
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/matched_elements_filter_dfw.h5
-rw-r--r--streamingvisitors/src/vespa/searchvisitor/matching_elements_filler.cpp3
-rw-r--r--vsm/src/vespa/vsm/vsm/docsumconfig.cpp3
5 files changed, 18 insertions, 10 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolver.java
index d86ed265b77..77064038053 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolver.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolver.java
@@ -48,11 +48,13 @@ public class MatchedElementsOnlyResolver extends Processor {
if (isComplexFieldWithOnlyStructFieldAttributes(sourceField)) {
field.setTransform(SummaryTransform.MATCHED_ATTRIBUTE_ELEMENTS_FILTER);
}
- } else if (isSupportedAttributeField(sourceField)) {
- field.setTransform(SummaryTransform.MATCHED_ATTRIBUTE_ELEMENTS_FILTER);
+ } else if (isSupportedMultiValueField(sourceField)) {
+ if (sourceField.doesAttributing()) {
+ field.setTransform(SummaryTransform.MATCHED_ATTRIBUTE_ELEMENTS_FILTER);
+ }
} else if (validate) {
fail(summary, field, "'matched-elements-only' is not supported for this field type. " +
- "Supported field types are: array attribute, weighted set attribute, " +
+ "Supported field types are: array of primitive, weighted set of primitive, " +
"array of simple struct, map of primitive type to simple struct, " +
"and map of primitive type to primitive type");
}
@@ -60,10 +62,9 @@ public class MatchedElementsOnlyResolver extends Processor {
// else case is handled in SummaryFieldsMustHaveValidSource
}
- private boolean isSupportedAttributeField(ImmutableSDField sourceField) {
+ private boolean isSupportedMultiValueField(ImmutableSDField sourceField) {
var type = sourceField.getDataType();
- return sourceField.doesAttributing() &&
- (isArrayOfPrimitiveType(type) || isWeightedsetOfPrimitiveType(type));
+ return (isArrayOfPrimitiveType(type) || isWeightedsetOfPrimitiveType(type));
}
private boolean isArrayOfPrimitiveType(DataType type) {
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
index 0ef696df6cf..ab98706fd44 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
@@ -149,10 +149,10 @@ public class MatchedElementsOnlyResolverTestCase {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("For search 'test', document summary 'default', summary field 'my_field': " +
"'matched-elements-only' is not supported for this field type. " +
- "Supported field types are: array attribute, weighted set attribute, " +
+ "Supported field types are: array of primitive, weighted set of primitive, " +
"array of simple struct, map of primitive type to simple struct, " +
"and map of primitive type to primitive type");
- buildSearch(joinLines("field my_field type array<string> {",
+ buildSearch(joinLines("field my_field type string {",
" indexing: summary",
" summary: matched-elements-only",
"}"));
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/matched_elements_filter_dfw.h b/searchsummary/src/vespa/searchsummary/docsummary/matched_elements_filter_dfw.h
index 087ddfd8d40..353f0df8bee 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/matched_elements_filter_dfw.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/matched_elements_filter_dfw.h
@@ -9,8 +9,9 @@ namespace search::attribute { class IAttributeContext; }
namespace search::docsummary {
/**
- * Field writer that filters matched elements (according to the query) from a complex field
- * (map of primitives, map of struct, array of struct) that is retrieved from the document store.
+ * Field writer that filters matched elements (according to the query) from a multi-value or complex field
+ * (array of primitive, weighted set of primitive, map of primitives, map of struct, array of struct)
+ * that is retrieved from the document store.
*/
class MatchedElementsFilterDFW : public IDocsumFieldWriter {
private:
diff --git a/streamingvisitors/src/vespa/searchvisitor/matching_elements_filler.cpp b/streamingvisitors/src/vespa/searchvisitor/matching_elements_filler.cpp
index fe717313ca4..d51bd57e942 100644
--- a/streamingvisitors/src/vespa/searchvisitor/matching_elements_filler.cpp
+++ b/streamingvisitors/src/vespa/searchvisitor/matching_elements_filler.cpp
@@ -83,6 +83,9 @@ Matcher::select_query_nodes(const MatchingElementsFields& fields, const QueryNod
if (fields.has_struct_field(query_term->getIndex())) {
_sub_field_terms.emplace_back(fields.get_enclosing_field(query_term->getIndex()), query_term);
}
+ if (fields.has_field(query_term->getIndex())) {
+ _sub_field_terms.emplace_back(query_term->getIndex(), query_term);
+ }
} else if (auto and_not = as<AndNotQueryNode>(query_node)) {
select_query_nodes(fields, *(*and_not)[0]);
} else if (auto intermediate = as<QueryConnector>(query_node)) {
diff --git a/vsm/src/vespa/vsm/vsm/docsumconfig.cpp b/vsm/src/vespa/vsm/vsm/docsumconfig.cpp
index 2512bea26df..fb25df83ded 100644
--- a/vsm/src/vespa/vsm/vsm/docsumconfig.cpp
+++ b/vsm/src/vespa/vsm/vsm/docsumconfig.cpp
@@ -26,6 +26,9 @@ void populate_fields(MatchingElementsFields& fields, VsmfieldsConfig& fields_con
if (spec.name.substr(0, prefix.size()) == prefix) {
fields.add_mapping(field_name, spec.name);
}
+ if (spec.name == field_name) {
+ fields.add_field(field_name);
+ }
}
}