diff options
author | Geir Storli <geirst@oath.com> | 2017-12-06 16:42:51 -0800 |
---|---|---|
committer | Geir Storli <geirst@oath.com> | 2017-12-06 16:42:51 -0800 |
commit | a9adc2795c1a4daa02ac5e98635ffeb13732ed1b (patch) | |
tree | a9acba2db897eeede1cc2712cbb1c70d27174f66 /config-model | |
parent | 8eca6284aa54563c0f0ba3fca1e2b2634a310cb5 (diff) |
Fix such that a predicate field can be imported from a parent into a child type.
Diffstat (limited to 'config-model')
6 files changed, 46 insertions, 1 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java index a70e77a17a2..c8918f39834 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java @@ -79,7 +79,12 @@ public class ImmutableImportedSDField implements ImmutableSDField { @Override public Index getIndex(String name) { - throw createUnsupportedException(); + if (!importedField.fieldName().equals(name)) { + throw new IllegalArgumentException("Getting an index (" + name + ") with different name than the imported field (" + + importedField.fieldName() + ") is not supported"); + } + String targetIndexName = importedField.targetField().getName(); + return importedField.targetField().getIndex(targetIndexName); } @Override diff --git a/config-model/src/test/derived/importedfields/attributes.cfg b/config-model/src/test/derived/importedfields/attributes.cfg index 62fe0052bc3..f51bbc012b9 100644 --- a/config-model/src/test/derived/importedfields/attributes.cfg +++ b/config-model/src/test/derived/importedfields/attributes.cfg @@ -138,3 +138,23 @@ attribute[].upperbound 9223372036854775807 attribute[].densepostinglistthreshold 0.4 attribute[].tensortype "" attribute[].imported true +attribute[].name "my_predicate_field" +attribute[].datatype PREDICATE +attribute[].collectiontype SINGLE +attribute[].removeifzero false +attribute[].createifnonexistent false +attribute[].fastsearch false +attribute[].huge false +attribute[].sortascending true +attribute[].sortfunction UCA +attribute[].sortstrength PRIMARY +attribute[].sortlocale "" +attribute[].enablebitvectors false +attribute[].enableonlybitvector false +attribute[].fastaccess false +attribute[].arity 8 +attribute[].lowerbound 5 +attribute[].upperbound 300 +attribute[].densepostinglistthreshold 0.4 +attribute[].tensortype "" +attribute[].imported true diff --git a/config-model/src/test/derived/importedfields/child.sd b/config-model/src/test/derived/importedfields/child.sd index 703451c1293..07fa7d15719 100644 --- a/config-model/src/test/derived/importedfields/child.sd +++ b/config-model/src/test/derived/importedfields/child.sd @@ -9,6 +9,7 @@ search child { import field b_ref.string_field as my_string_field {} import field a_ref.int_array_field as my_int_array_field {} import field a_ref.int_wset_field as my_int_wset_field {} + import field a_ref.predicate_field as my_predicate_field {} fieldset myfieldset { fields: my_int_field, my_string_field diff --git a/config-model/src/test/derived/importedfields/imported-fields.cfg b/config-model/src/test/derived/importedfields/imported-fields.cfg index 3f2a083bdc2..59413ca5eb7 100644 --- a/config-model/src/test/derived/importedfields/imported-fields.cfg +++ b/config-model/src/test/derived/importedfields/imported-fields.cfg @@ -18,3 +18,8 @@ attribute[].referencefield "a_ref" attribute[].targetfield "int_wset_field" attribute[].datatype NONE attribute[].collectiontype SINGLE +attribute[].name "my_predicate_field" +attribute[].referencefield "a_ref" +attribute[].targetfield "predicate_field" +attribute[].datatype NONE +attribute[].collectiontype SINGLE diff --git a/config-model/src/test/derived/importedfields/index-info.cfg b/config-model/src/test/derived/importedfields/index-info.cfg index 7cb53c480ce..adba0036409 100644 --- a/config-model/src/test/derived/importedfields/index-info.cfg +++ b/config-model/src/test/derived/importedfields/index-info.cfg @@ -49,6 +49,12 @@ indexinfo[].command[].indexname "my_int_wset_field" indexinfo[].command[].command "multivalue" indexinfo[].command[].indexname "my_int_wset_field" indexinfo[].command[].command "attribute" +indexinfo[].command[].indexname "my_predicate_field" +indexinfo[].command[].command "predicate-bounds [5..300]" +indexinfo[].command[].indexname "my_predicate_field" +indexinfo[].command[].command "index" +indexinfo[].command[].indexname "my_predicate_field" +indexinfo[].command[].command "attribute" indexinfo[].command[].indexname "myfieldset" indexinfo[].command[].command "attribute" indexinfo[].command[].indexname "myfieldset" diff --git a/config-model/src/test/derived/importedfields/parent_a.sd b/config-model/src/test/derived/importedfields/parent_a.sd index eea12375daf..edc81df5609 100644 --- a/config-model/src/test/derived/importedfields/parent_a.sd +++ b/config-model/src/test/derived/importedfields/parent_a.sd @@ -10,5 +10,13 @@ search parent_a { field int_wset_field type weightedset<int> { indexing: attribute } + field predicate_field type predicate { + indexing: attribute + index { + arity: 8 + lower-bound: 5 + upper-bound: 300 + } + } } } |