aboutsummaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2018-11-27 13:45:11 +0000
committerTor Egge <Tor.Egge@oath.com>2018-11-28 11:16:23 +0000
commit554f4dc0126015c5b2ce3d4c178281e4de3e32a5 (patch)
treed654cf8155ffac7f3910dd52cdf512f7a695cfce /config-model
parent2cf235d0a77e71dba5884273579c549ca844743a (diff)
Generate index info config for imported complex fields.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java22
-rw-r--r--config-model/src/test/derived/imported_struct_fields/index-info.cfg18
2 files changed, 39 insertions, 1 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java
index a719a67274f..ae5494ec636 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java
@@ -11,6 +11,9 @@ import com.yahoo.vespa.documentmodel.SummaryField;
import com.yahoo.search.config.IndexInfoConfig;
import java.util.*;
+import java.util.stream.Stream;
+
+import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isMapOfSimpleStruct;
/**
* Per-index commands which should be applied to queries prior to searching
@@ -73,6 +76,9 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer {
addIndexCommand(summaryField.getName(), CMD_HIGHLIGHT);
}
}
+ search.importedFields().map(fields -> fields.complexFields().values().stream()).
+ orElse(Stream.empty()).
+ forEach(field -> deriveImportedComplexField(field));
}
@Override
@@ -82,6 +88,22 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer {
}
}
+ private void deriveImportedComplexField(ImportedField field) {
+ ImmutableSDField targetField = field.targetField();
+ while (targetField.isImportedField()) {
+ targetField = targetField.getBackingField();
+ }
+ addStructFieldIndexCommand(field.fieldName());
+ if (isMapOfSimpleStruct(targetField)) {
+ addStructFieldIndexCommand(field.fieldName() + ".value");
+ }
+ }
+
+ private void addStructFieldIndexCommand(String fieldName) {
+ addIndexCommand(fieldName, CMD_MULTIVALUE);
+ addIndexCommand(fieldName, CMD_INDEX);
+ }
+
private String toSpaceSeparated(Collection c) {
StringBuffer b = new StringBuffer();
for (Iterator i = c.iterator(); i.hasNext();) {
diff --git a/config-model/src/test/derived/imported_struct_fields/index-info.cfg b/config-model/src/test/derived/imported_struct_fields/index-info.cfg
index c9b764a66e9..b33b9f09951 100644
--- a/config-model/src/test/derived/imported_struct_fields/index-info.cfg
+++ b/config-model/src/test/derived/imported_struct_fields/index-info.cfg
@@ -56,4 +56,20 @@ indexinfo[0].command[26].command "index"
indexinfo[0].command[27].indexname "my_str_int_map.value"
indexinfo[0].command[27].command "attribute"
indexinfo[0].command[28].indexname "my_str_int_map.value"
-indexinfo[0].command[28].command "numerical" \ No newline at end of file
+indexinfo[0].command[28].command "numerical"
+indexinfo[0].command[29].indexname "my_elem_array"
+indexinfo[0].command[29].command "multivalue"
+indexinfo[0].command[30].indexname "my_elem_array"
+indexinfo[0].command[30].command "index"
+indexinfo[0].command[31].indexname "my_elem_map"
+indexinfo[0].command[31].command "multivalue"
+indexinfo[0].command[32].indexname "my_elem_map"
+indexinfo[0].command[32].command "index"
+indexinfo[0].command[33].indexname "my_elem_map.value"
+indexinfo[0].command[33].command "multivalue"
+indexinfo[0].command[34].indexname "my_elem_map.value"
+indexinfo[0].command[34].command "index"
+indexinfo[0].command[35].indexname "my_str_int_map"
+indexinfo[0].command[35].command "multivalue"
+indexinfo[0].command[36].indexname "my_str_int_map"
+indexinfo[0].command[36].command "index" \ No newline at end of file