aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-03-04 17:52:56 +0000
committerArne H Juul <arnej@yahooinc.com>2022-03-04 17:59:21 +0000
commitea589cb32a232e7f3eb9072e18c1f6455b53929e (patch)
tree53324bf071009724337d4f61f64749d77b1bdf03 /config-model/src/main/java/com/yahoo
parent4f88c2febd251889052c4f519f0d53a0c7fbd946 (diff)
populate extra fields
* for consistency, ensure we call populateWithStructFields etc also for fields declared outside the document block.
Diffstat (limited to 'config-model/src/main/java/com/yahoo')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/Application.java1
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/FieldOperationApplierForStructs.java33
2 files changed, 25 insertions, 9 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Application.java b/config-model/src/main/java/com/yahoo/searchdefinition/Application.java
index 64688a7e70d..16eef798acd 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/Application.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/Application.java
@@ -84,6 +84,7 @@ public class Application {
List<Schema> schemasSomewhatOrdered = new ArrayList<>(schemas);
for (Schema schema : new SearchOrderer().order(schemasSomewhatOrdered)) {
+ new FieldOperationApplierForStructs().processSchemaFields(schema);
new FieldOperationApplierForSearch().process(schema); // TODO: Why is this not in the regular list?
new Processing(properties).process(schema,
logger,
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/FieldOperationApplierForStructs.java b/config-model/src/main/java/com/yahoo/searchdefinition/FieldOperationApplierForStructs.java
index 16bf37902f5..5e5623e2319 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/FieldOperationApplierForStructs.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/FieldOperationApplierForStructs.java
@@ -35,17 +35,32 @@ public class FieldOperationApplierForStructs extends FieldOperationApplier {
Iterator<Field> fields = anyType.fieldIterator();
while (fields.hasNext()) {
SDField field = (SDField) fields.next();
- DataType structUsedByField = field.getFirstStructRecursive();
- if (structUsedByField == null) {
- continue;
- }
- if (structUsedByField.getName().equals(structType.getName())) {
- //this field is using this type!!
- field.populateWithStructFields(sdoc, field.getName(), field.getDataType(), 0);
- field.populateWithStructMatching(sdoc, field.getDataType(), field.getMatching());
- }
+ maybePopulateField(sdoc, field, structType);
}
}
}
+ private void maybePopulateField(SDDocumentType sdoc, SDField field, SDDocumentType structType) {
+ DataType structUsedByField = field.getFirstStructRecursive();
+ if (structUsedByField == null) {
+ return;
+ }
+ if (structUsedByField.getName().equals(structType.getName())) {
+ //this field is using this type!!
+ field.populateWithStructFields(sdoc, field.getName(), field.getDataType(), 0);
+ field.populateWithStructMatching(sdoc, field.getDataType(), field.getMatching());
+ }
+ }
+
+ public void processSchemaFields(Schema schema) {
+ var sdoc = schema.getDocument();
+ if (sdoc == null) return;
+ for (SDDocumentType type : sdoc.getAllTypes()) {
+ if (type.isStruct()) {
+ for (SDField field : schema.allExtraFields()) {
+ maybePopulateField(sdoc, field, type);
+ }
+ }
+ }
+ }
}