diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-03-04 17:52:56 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2022-03-04 17:59:21 +0000 |
commit | ea589cb32a232e7f3eb9072e18c1f6455b53929e (patch) | |
tree | 53324bf071009724337d4f61f64749d77b1bdf03 /config-model | |
parent | 4f88c2febd251889052c4f519f0d53a0c7fbd946 (diff) |
populate extra fields
* for consistency, ensure we call populateWithStructFields etc
also for fields declared outside the document block.
Diffstat (limited to 'config-model')
6 files changed, 85 insertions, 33 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); + } + } + } + } } diff --git a/config-model/src/test/derived/advanced/index-info.cfg b/config-model/src/test/derived/advanced/index-info.cfg index c693597a75e..cf33b038700 100644 --- a/config-model/src/test/derived/advanced/index-info.cfg +++ b/config-model/src/test/derived/advanced/index-info.cfg @@ -51,6 +51,18 @@ indexinfo[].command[].indexname "debug" indexinfo[].command[].command "plain-tokens" indexinfo[].command[].indexname "debug" indexinfo[].command[].command "type string" +indexinfo[].command[].indexname "location.x" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "location.x" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "location.x" +indexinfo[].command[].command "type int" +indexinfo[].command[].indexname "location.y" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "location.y" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "location.y" +indexinfo[].command[].command "type int" indexinfo[].command[].indexname "location" indexinfo[].command[].command "default-position" indexinfo[].command[].indexname "location" diff --git a/config-model/src/test/derived/multiplesummaries/ilscripts.cfg b/config-model/src/test/derived/multiplesummaries/ilscripts.cfg index 5434b0770f7..6429932ab0e 100644 --- a/config-model/src/test/derived/multiplesummaries/ilscripts.cfg +++ b/config-model/src/test/derived/multiplesummaries/ilscripts.cfg @@ -1,27 +1,27 @@ maxtermoccurrences 100 fieldmatchmaxlength 1000000 ilscript[].doctype "multiplesummaries" -ilscript[].docfield[0] "a" -ilscript[].docfield[1] "adynamic" -ilscript[].docfield[2] "abolded" -ilscript[].docfield[3] "b" -ilscript[].docfield[4] "c" -ilscript[].docfield[5] "d" -ilscript[].docfield[6] "e" -ilscript[].docfield[7] "f" -ilscript[].docfield[8] "g" -ilscript[].docfield[9] "h" -ilscript[].docfield[10] "loc" -ilscript[].docfield[11] "mytags" -ilscript[].content[0] "clear_state | guard { input loc | to_pos | zcurve | attribute loc_pos_zcurve; }" -ilscript[].content[1] "clear_state | guard { input a | tokenize normalize stem:\"BEST\" | summary abolded2 | summary aboldeddynamic | summary adynamic2 | attribute a; }" -ilscript[].content[2] "clear_state | guard { input adynamic | tokenize normalize stem:\"BEST\" | summary adynamic | attribute adynamic; }" -ilscript[].content[3] "clear_state | guard { input abolded | tokenize normalize stem:\"BEST\" | summary abolded | attribute abolded; }" -ilscript[].content[4] "clear_state | guard { input b | summary anotherb | summary b; }" -ilscript[].content[5] "clear_state | guard { input c | summary c | attribute c; }" -ilscript[].content[6] "clear_state | guard { input d | tokenize normalize stem:\"BEST\" | summary d; }" -ilscript[].content[7] "clear_state | guard { input e | tokenize normalize stem:\"BEST\" | summary dynamice | summary e; }" -ilscript[].content[8] "clear_state | guard { input f | summary f; }" -ilscript[].content[9] "clear_state | guard { input g | summary g; }" -ilscript[].content[10] "clear_state | guard { input h | summary h; }" -ilscript[].content[11] "clear_state | guard { input mytags | for_each { tokenize normalize stem:\"BEST\" } | index mytags; }" +ilscript[].docfield[] "a" +ilscript[].docfield[] "adynamic" +ilscript[].docfield[] "abolded" +ilscript[].docfield[] "b" +ilscript[].docfield[] "c" +ilscript[].docfield[] "d" +ilscript[].docfield[] "e" +ilscript[].docfield[] "f" +ilscript[].docfield[] "g" +ilscript[].docfield[] "h" +ilscript[].docfield[] "loc" +ilscript[].docfield[] "mytags" +ilscript[].content[] "clear_state | guard { input loc | to_pos | zcurve | attribute loc_pos_zcurve; }" +ilscript[].content[] "clear_state | guard { input a | tokenize normalize stem:\"BEST\" | summary abolded2 | summary aboldeddynamic | summary adynamic2 | attribute a; }" +ilscript[].content[] "clear_state | guard { input adynamic | tokenize normalize stem:\"BEST\" | summary adynamic | attribute adynamic; }" +ilscript[].content[] "clear_state | guard { input abolded | tokenize normalize stem:\"BEST\" | summary abolded | attribute abolded; }" +ilscript[].content[] "clear_state | guard { input b | summary anotherb | summary b; }" +ilscript[].content[] "clear_state | guard { input c | summary c | attribute c; }" +ilscript[].content[] "clear_state | guard { input d | tokenize normalize stem:\"BEST\" | summary d; }" +ilscript[].content[] "clear_state | guard { input e | tokenize normalize stem:\"BEST\" | summary dynamice | summary e; }" +ilscript[].content[] "clear_state | guard { input f | summary f; }" +ilscript[].content[] "clear_state | guard { input g | summary g; }" +ilscript[].content[] "clear_state | guard { input h | summary h; }" +ilscript[].content[] "clear_state | guard { input mytags | for_each { tokenize normalize stem:\"BEST\" } | index mytags; }" diff --git a/config-model/src/test/derived/multiplesummaries/index-info.cfg b/config-model/src/test/derived/multiplesummaries/index-info.cfg index d5002535761..6167dcbef02 100644 --- a/config-model/src/test/derived/multiplesummaries/index-info.cfg +++ b/config-model/src/test/derived/multiplesummaries/index-info.cfg @@ -111,6 +111,18 @@ indexinfo[].command[].indexname "dynamice" indexinfo[].command[].command "index" indexinfo[].command[].indexname "dynamice" indexinfo[].command[].command "type string" +indexinfo[].command[].indexname "loc_pos.x" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "loc_pos.x" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "loc_pos.x" +indexinfo[].command[].command "type int" +indexinfo[].command[].indexname "loc_pos.y" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "loc_pos.y" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "loc_pos.y" +indexinfo[].command[].command "type int" indexinfo[].command[].indexname "loc_pos" indexinfo[].command[].command "default-position" indexinfo[].command[].indexname "loc_pos" diff --git a/config-model/src/test/derived/position_extra/index-info.cfg b/config-model/src/test/derived/position_extra/index-info.cfg index 45813140b1d..97521c14a6a 100644 --- a/config-model/src/test/derived/position_extra/index-info.cfg +++ b/config-model/src/test/derived/position_extra/index-info.cfg @@ -7,6 +7,18 @@ indexinfo[].command[].indexname "pos_str" indexinfo[].command[].command "index" indexinfo[].command[].indexname "pos_str" indexinfo[].command[].command "type string" +indexinfo[].command[].indexname "pos_ext.x" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "pos_ext.x" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "pos_ext.x" +indexinfo[].command[].command "type int" +indexinfo[].command[].indexname "pos_ext.y" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "pos_ext.y" +indexinfo[].command[].command "numerical" +indexinfo[].command[].indexname "pos_ext.y" +indexinfo[].command[].command "type int" indexinfo[].command[].indexname "pos_ext" indexinfo[].command[].command "default-position" indexinfo[].command[].indexname "pos_ext" |