diff options
Diffstat (limited to 'config-model')
14 files changed, 216 insertions, 167 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java index 55260b6e68f..dd2ffba20ec 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java @@ -290,14 +290,16 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, if (dataType instanceof CollectionDataType) { dataType = ((CollectionDataType)dataType).getNestedType(); } - SDDocumentType subType = sdoc != null ? sdoc.getType(dataType.getName()) : null; - if (subType == null) { - throw new IllegalArgumentException("Could not find struct '" + dataType.getName() + "'."); - } - for (Field field : subType.fieldSet()) { - SDField subField = new SDField(sdoc, name.concat(".").concat(field.getName()), field.getDataType(), - isHeader, subType, new Matching(), true, recursion + 1); - structFields.put(field.getName(), subField); + if (dataType instanceof StructDataType) { + SDDocumentType subType = sdoc != null ? sdoc.getType(dataType.getName()) : null; + if (subType == null) { + throw new IllegalArgumentException("Could not find struct '" + dataType.getName() + "'."); + } + for (Field field : subType.fieldSet()) { + SDField subField = new SDField(sdoc, name.concat(".").concat(field.getName()), field.getDataType(), + isHeader, subType, new Matching(), true, recursion + 1); + structFields.put(field.getName(), subField); + } } } } @@ -305,41 +307,43 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, public void populateWithStructMatching(SDDocumentType sdoc, String name, DataType dataType, Matching superFieldMatching) { DataType dt = getFirstStructOrMapRecursive(); - if (dt != null) { - if (dataType instanceof MapDataType) { - MapDataType mdt = (MapDataType) dataType; - - Matching keyFieldMatching = new Matching(); - if (superFieldMatching != null) { - keyFieldMatching.merge(superFieldMatching); - } - SDField keyField = structFields.get(name.concat(".key")); - if (keyField != null) { - keyField.populateWithStructMatching(sdoc, name.concat(".key"), mdt.getKeyType(), keyFieldMatching); - keyField.setMatching(keyFieldMatching); - } + if (dt == null) { + return; + } + if (dataType instanceof MapDataType) { + MapDataType mdt = (MapDataType) dataType; - Matching valueFieldMatching = new Matching(); - if (superFieldMatching != null) { - valueFieldMatching.merge(superFieldMatching); - } - SDField valueField = structFields.get(name.concat(".value")); - if (valueField != null) { - valueField.populateWithStructMatching(sdoc, name.concat(".value"), mdt.getValueType(), - valueFieldMatching); - valueField.setMatching(valueFieldMatching); - } + Matching keyFieldMatching = new Matching(); + if (superFieldMatching != null) { + keyFieldMatching.merge(superFieldMatching); + } + SDField keyField = structFields.get(name.concat(".key")); + if (keyField != null) { + keyField.populateWithStructMatching(sdoc, name.concat(".key"), mdt.getKeyType(), keyFieldMatching); + keyField.setMatching(keyFieldMatching); + } - } else { + Matching valueFieldMatching = new Matching(); + if (superFieldMatching != null) { + valueFieldMatching.merge(superFieldMatching); + } + SDField valueField = structFields.get(name.concat(".value")); + if (valueField != null) { + valueField.populateWithStructMatching(sdoc, name.concat(".value"), mdt.getValueType(), + valueFieldMatching); + valueField.setMatching(valueFieldMatching); + } - if (dataType instanceof CollectionDataType) { - dataType = ((CollectionDataType)dataType).getNestedType(); - } + } else { + if (dataType instanceof CollectionDataType) { + dataType = ((CollectionDataType)dataType).getNestedType(); + } + if (dataType instanceof StructDataType) { SDDocumentType subType = sdoc != null ? sdoc.getType(dataType.getName()) : null; if (subType != null) { for (Field f : subType.fieldSet()) { if (f instanceof SDField) { - SDField field = (SDField)f; + SDField field = (SDField) f; Matching subFieldMatching = new Matching(); if (superFieldMatching != null) { subFieldMatching.merge(superFieldMatching); @@ -348,11 +352,11 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, SDField subField = structFields.get(field.getName()); if (subField != null) { subField.populateWithStructMatching(sdoc, name.concat(".").concat(field.getName()), field.getDataType(), - subFieldMatching); + subFieldMatching); subField.setMatching(subFieldMatching); } } else { - throw new IllegalArgumentException("Field in struct is not SDField " + f.getName()); + throw new IllegalArgumentException("Field in struct is not SDField " + f.getName()); } } } else { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypes.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypes.java index 076161a8584..1994b1096ce 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypes.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypes.java @@ -2,6 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.document.ArrayDataType; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.DataType; import com.yahoo.document.MapDataType; @@ -26,20 +27,30 @@ public class DisallowComplexMapAndWsetKeyTypes extends Processor { public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - // TODO also traverse struct types to search for bad map or wset types there. Do this after document manager is fixed, do - // not start using the static stuff on SDDocumentTypes any more. + // TODO also traverse struct types to search for bad map or wset types. + // Do this after document manager is fixed, do not start using the static stuff on SDDocumentTypes any more. for (SDField field : search.allConcreteFields()) { - if (field.getDataType() instanceof WeightedSetDataType) { - DataType nestedType = ((WeightedSetDataType)field.getDataType()).getNestedType(); - if ( ! (nestedType instanceof PrimitiveDataType)) { - fail(search, field, "Weighted set must have a primitive key type."); - } - } else if (field.getDataType() instanceof MapDataType) { - if ( ! (((MapDataType)field.getDataType()).getKeyType() instanceof PrimitiveDataType)) { - fail(search, field, "Map key type must be a primitive type"); - } + checkFieldType(field, field.getDataType()); + } + } + + private void checkFieldType(SDField field, DataType dataType) { + if (dataType instanceof ArrayDataType) { + DataType nestedType = ((ArrayDataType) dataType).getNestedType(); + checkFieldType(field, nestedType); + } else if (dataType instanceof WeightedSetDataType) { + DataType nestedType = ((WeightedSetDataType) dataType).getNestedType(); + if ( ! (nestedType instanceof PrimitiveDataType)) { + fail(search, field, "Weighted set must have a primitive key type."); } + } else if (dataType instanceof MapDataType) { + DataType keyType = ((MapDataType) dataType).getKeyType(); + if ( ! (keyType instanceof PrimitiveDataType)) { + fail(search, field, "Map key type must be a primitive type."); + } + checkFieldType(field, ((MapDataType) dataType).getValueType()); } + } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/HttpProvider.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/HttpProvider.java index 983f903310f..62b2f2ccbc6 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/HttpProvider.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/HttpProvider.java @@ -28,20 +28,6 @@ public class HttpProvider extends Provider implements ProviderConfig.Producer, @SuppressWarnings("deprecation") private final com.yahoo.search.searchchain.model.federation.HttpProviderSpec providerSpec; - //TODO: For backward compatibility only, eliminate this later - private BinaryScaledAmount cacheSize; - - public double getCacheWeight() { - return providerSpec.cacheWeight; - } - - /** - * TODO: remove, for backward compatibility only. - */ - public void setCacheSize(BinaryScaledAmount cacheSize) { - this.cacheSize = cacheSize; - } - /* * Config producer for the contained http searcher.. */ @@ -101,9 +87,7 @@ public class HttpProvider extends Provider implements ProviderConfig.Producer, } public int cacheSizeMB() { - return providerSpec.cacheSizeMB != null ? - providerSpec.cacheSizeMB : - (int) cacheSize.as(BinaryPrefix.mega); + return providerSpec.cacheSizeMB != null ? providerSpec.cacheSizeMB : 0; } @Override diff --git a/config-model/src/test/configmodel/types/documentmanager.cfg b/config-model/src/test/configmodel/types/documentmanager.cfg index 6b01934307a..aaaebccecfd 100644 --- a/config-model/src/test/configmodel/types/documentmanager.cfg +++ b/config-model/src/test/configmodel/types/documentmanager.cfg @@ -212,11 +212,11 @@ datatype[24].structtype[0].field[27].detailedtype "" datatype[24].structtype[0].field[28].name "summaryfeatures" datatype[24].structtype[0].field[28].datatype 2 datatype[24].structtype[0].field[28].detailedtype "" -datatype[25].id 171503364 -datatype[25].maptype[0].keytype 1707615575 -datatype[25].maptype[0].valtype 0 -datatype[26].id 1100964733 -datatype[26].arraytype[0].datatype 171503364 +datatype[25].id -372512406 +datatype[25].maptype[0].keytype 0 +datatype[25].maptype[0].valtype 1707615575 +datatype[26].id 1416345047 +datatype[26].arraytype[0].datatype -372512406 datatype[27].id 348447225 datatype[27].structtype[0].name "types.body" datatype[27].structtype[0].version 0 @@ -225,7 +225,7 @@ datatype[27].structtype[0].compresslevel 0 datatype[27].structtype[0].compressthreshold 95 datatype[27].structtype[0].compressminsize 800 datatype[27].structtype[0].field[0].name "complexarray" -datatype[27].structtype[0].field[0].datatype 1100964733 +datatype[27].structtype[0].field[0].datatype 1416345047 datatype[27].structtype[0].field[0].detailedtype "" datatype[28].id -853072901 datatype[28].documenttype[0].name "types" diff --git a/config-model/src/test/configmodel/types/documenttypes.cfg b/config-model/src/test/configmodel/types/documenttypes.cfg index dc7962adec7..97785618e8e 100644 --- a/config-model/src/test/configmodel/types/documenttypes.cfg +++ b/config-model/src/test/configmodel/types/documenttypes.cfg @@ -560,11 +560,11 @@ documenttype[0].datatype[23].sstruct.field[28].id 1840337115 documenttype[0].datatype[23].sstruct.field[28].id_v6 1981648971 documenttype[0].datatype[23].sstruct.field[28].datatype 2 documenttype[0].datatype[23].sstruct.field[28].detailedtype "" -documenttype[0].datatype[24].id 171503364 +documenttype[0].datatype[24].id -372512406 documenttype[0].datatype[24].type MAP documenttype[0].datatype[24].array.element.id 0 -documenttype[0].datatype[24].map.key.id 1707615575 -documenttype[0].datatype[24].map.value.id 0 +documenttype[0].datatype[24].map.key.id 0 +documenttype[0].datatype[24].map.value.id 1707615575 documenttype[0].datatype[24].wset.key.id 0 documenttype[0].datatype[24].wset.createifnonexistent false documenttype[0].datatype[24].wset.removeifzero false @@ -575,9 +575,9 @@ documenttype[0].datatype[24].sstruct.compression.type NONE documenttype[0].datatype[24].sstruct.compression.level 0 documenttype[0].datatype[24].sstruct.compression.threshold 95 documenttype[0].datatype[24].sstruct.compression.minsize 200 -documenttype[0].datatype[25].id 1100964733 +documenttype[0].datatype[25].id 1416345047 documenttype[0].datatype[25].type ARRAY -documenttype[0].datatype[25].array.element.id 171503364 +documenttype[0].datatype[25].array.element.id -372512406 documenttype[0].datatype[25].map.key.id 0 documenttype[0].datatype[25].map.value.id 0 documenttype[0].datatype[25].wset.key.id 0 @@ -606,9 +606,9 @@ documenttype[0].datatype[26].sstruct.compression.level 0 documenttype[0].datatype[26].sstruct.compression.threshold 95 documenttype[0].datatype[26].sstruct.compression.minsize 200 documenttype[0].datatype[26].sstruct.field[0].name "complexarray" -documenttype[0].datatype[26].sstruct.field[0].id 1028383787 +documenttype[0].datatype[26].sstruct.field[0].id 795629533 documenttype[0].datatype[26].sstruct.field[0].id_v6 658530305 -documenttype[0].datatype[26].sstruct.field[0].datatype 1100964733 +documenttype[0].datatype[26].sstruct.field[0].datatype 1416345047 documenttype[0].datatype[26].sstruct.field[0].detailedtype "" documenttype[0].fieldsets{[document]}.fields[0] "Folders" documenttype[0].fieldsets{[document]}.fields[1] "abyte" diff --git a/config-model/src/test/configmodel/types/types.sd b/config-model/src/test/configmodel/types/types.sd index c55c5611bc5..f34a6776b11 100644 --- a/config-model/src/test/configmodel/types/types.sd +++ b/config-model/src/test/configmodel/types/types.sd @@ -92,7 +92,7 @@ search types { field arrarr type array<array<array<string>>> {header} field maparr type array<map<string, string>> {header} - field complexarray type array< map<array<array<string>>, int> > {body} + field complexarray type array< map<int, array<array<string>>> > {body} struct mystruct { field bytearr type array<byte>{} diff --git a/config-model/src/test/derived/complex/complex.sd b/config-model/src/test/derived/complex/complex.sd index 8fbfd216c3e..82aca00ebfc 100644 --- a/config-model/src/test/derived/complex/complex.sd +++ b/config-model/src/test/derived/complex/complex.sd @@ -41,7 +41,6 @@ search complex { field prefixenabled type string { indexing: index | attribute index: prefix - attribute: prefetch attribute: huge normalizing: none stemming: shortest @@ -58,12 +57,10 @@ search complex { field fleeting type array<float> { indexing: index | attribute - attribute: prefetch } field fleeting2 type float { indexing: index | attribute - attribute: prefetch } field foundat type long { diff --git a/config-model/src/test/derived/complex/summary.cfg b/config-model/src/test/derived/complex/summary.cfg index ff14dbba419..5bb472b5f41 100644 --- a/config-model/src/test/derived/complex/summary.cfg +++ b/config-model/src/test/derived/complex/summary.cfg @@ -1,43 +1,41 @@ defaultsummaryid 1506848752 -classes[].id 1506848752 -classes[].name "default" -classes[].fields[].name "woe" -classes[].fields[].type "longstring" -classes[].fields[].name "exact" -classes[].fields[].type "longstring" -classes[].fields[].name "title" -classes[].fields[].type "longstring" -classes[].fields[].name "dyntitle" -classes[].fields[].type "longstring" -classes[].fields[].name "source" -classes[].fields[].type "longstring" -classes[].fields[].name "stringfield" -classes[].fields[].type "longstring" -classes[].fields[].name "rankfeatures" -classes[].fields[].type "featuredata" -classes[].fields[].name "summaryfeatures" -classes[].fields[].type "featuredata" -classes[].fields[].name "documentid" -classes[].fields[].type "longstring" -classes[].id 28214929 -classes[].name "attributeprefetch" -classes[].fields[].name "year_sub" -classes[].fields[].type "integer" -classes[].fields[].name "prefixenabled" -classes[].fields[].type "longstring" -classes[].fields[].name "fleeting" -classes[].fields[].type "jsonstring" -classes[].fields[].name "fleeting2" -classes[].fields[].type "float" -classes[].fields[].name "foundat" -classes[].fields[].type "int64" -classes[].fields[].name "collapseby" -classes[].fields[].type "integer" -classes[].fields[].name "ts" -classes[].fields[].type "int64" -classes[].fields[].name "combineda" -classes[].fields[].type "integer" -classes[].fields[].name "rankfeatures" -classes[].fields[].type "featuredata" -classes[].fields[].name "summaryfeatures" -classes[].fields[].type "featuredata" +classes[0].id 1506848752 +classes[0].name "default" +classes[0].fields[0].name "woe" +classes[0].fields[0].type "longstring" +classes[0].fields[1].name "exact" +classes[0].fields[1].type "longstring" +classes[0].fields[2].name "title" +classes[0].fields[2].type "longstring" +classes[0].fields[3].name "dyntitle" +classes[0].fields[3].type "longstring" +classes[0].fields[4].name "source" +classes[0].fields[4].type "longstring" +classes[0].fields[5].name "stringfield" +classes[0].fields[5].type "longstring" +classes[0].fields[6].name "rankfeatures" +classes[0].fields[6].type "featuredata" +classes[0].fields[7].name "summaryfeatures" +classes[0].fields[7].type "featuredata" +classes[0].fields[8].name "documentid" +classes[0].fields[8].type "longstring" +classes[1].id 128090024 +classes[1].name "attributeprefetch" +classes[1].fields[0].name "year_sub" +classes[1].fields[0].type "integer" +classes[1].fields[1].name "prefixenabled" +classes[1].fields[1].type "longstring" +classes[1].fields[2].name "fleeting2" +classes[1].fields[2].type "float" +classes[1].fields[3].name "foundat" +classes[1].fields[3].type "int64" +classes[1].fields[4].name "collapseby" +classes[1].fields[4].type "integer" +classes[1].fields[5].name "ts" +classes[1].fields[5].type "int64" +classes[1].fields[6].name "combineda" +classes[1].fields[6].type "integer" +classes[1].fields[7].name "rankfeatures" +classes[1].fields[7].type "featuredata" +classes[1].fields[8].name "summaryfeatures" +classes[1].fields[8].type "featuredata"
\ No newline at end of file diff --git a/config-model/src/test/derived/complex/summarymap.cfg b/config-model/src/test/derived/complex/summarymap.cfg index 1d4b57a49a7..f7ad249ae86 100644 --- a/config-model/src/test/derived/complex/summarymap.cfg +++ b/config-model/src/test/derived/complex/summarymap.cfg @@ -1,34 +1,31 @@ defaultoutputclass -1 -override[].field "dyntitle" -override[].command "dynamicteaser" -override[].arguments "dyntitle" -override[].field "rankfeatures" -override[].command "rankfeatures" -override[].arguments "" -override[].field "summaryfeatures" -override[].command "summaryfeatures" -override[].arguments "" -override[].field "year_sub" -override[].command "attribute" -override[].arguments "year_sub" -override[].field "prefixenabled" -override[].command "attribute" -override[].arguments "prefixenabled" -override[].field "fleeting" -override[].command "attribute" -override[].arguments "fleeting" -override[].field "fleeting2" -override[].command "attribute" -override[].arguments "fleeting2" -override[].field "foundat" -override[].command "attribute" -override[].arguments "foundat" -override[].field "collapseby" -override[].command "attribute" -override[].arguments "collapseby" -override[].field "ts" -override[].command "attribute" -override[].arguments "ts" -override[].field "combineda" -override[].command "attribute" -override[].arguments "combineda" +override[0].field "dyntitle" +override[0].command "dynamicteaser" +override[0].arguments "dyntitle" +override[1].field "rankfeatures" +override[1].command "rankfeatures" +override[1].arguments "" +override[2].field "summaryfeatures" +override[2].command "summaryfeatures" +override[2].arguments "" +override[3].field "year_sub" +override[3].command "attribute" +override[3].arguments "year_sub" +override[4].field "prefixenabled" +override[4].command "attribute" +override[4].arguments "prefixenabled" +override[5].field "fleeting2" +override[5].command "attribute" +override[5].arguments "fleeting2" +override[6].field "foundat" +override[6].command "attribute" +override[6].arguments "foundat" +override[7].field "collapseby" +override[7].command "attribute" +override[7].arguments "collapseby" +override[8].field "ts" +override[8].command "attribute" +override[8].arguments "ts" +override[9].field "combineda" +override[9].command "attribute" +override[9].arguments "combineda"
\ No newline at end of file diff --git a/config-model/src/test/derived/mlr/mlr.sd b/config-model/src/test/derived/mlr/mlr.sd index a6179f836f2..1a5354e3b30 100644 --- a/config-model/src/test/derived/mlr/mlr.sd +++ b/config-model/src/test/derived/mlr/mlr.sd @@ -5,7 +5,6 @@ search mlr { field a type string { indexing: index | summary | attribute - attribute: prefetch } field b type string { @@ -14,7 +13,6 @@ search mlr { field ranklog type string { indexing: attribute - attribute: prefetch } } } diff --git a/config-model/src/test/derived/types/documentmanager.cfg b/config-model/src/test/derived/types/documentmanager.cfg index c490db59736..647c26e1316 100644 --- a/config-model/src/test/derived/types/documentmanager.cfg +++ b/config-model/src/test/derived/types/documentmanager.cfg @@ -209,11 +209,11 @@ datatype[].structtype[].field[].detailedtype "" datatype[].structtype[].field[].name "summaryfeatures" datatype[].structtype[].field[].datatype 2 datatype[].structtype[].field[].detailedtype "" -datatype[].id 171503364 -datatype[].maptype[].keytype 1707615575 -datatype[].maptype[].valtype 0 -datatype[].id 1100964733 -datatype[].arraytype[].datatype 171503364 +datatype[].id -372512406 +datatype[].maptype[].keytype 0 +datatype[].maptype[].valtype 1707615575 +datatype[].id 1416345047 +datatype[].arraytype[].datatype -372512406 datatype[].id 348447225 datatype[].structtype[].name "types.body" datatype[].structtype[].version 0 @@ -222,7 +222,7 @@ datatype[].structtype[].compresslevel 0 datatype[].structtype[].compressthreshold 95 datatype[].structtype[].compressminsize 800 datatype[].structtype[].field[].name "complexarray" -datatype[].structtype[].field[].datatype 1100964733 +datatype[].structtype[].field[].datatype 1416345047 datatype[].structtype[].field[].detailedtype "" datatype[].id -853072901 datatype[].documenttype[].name "types" diff --git a/config-model/src/test/derived/types/types.sd b/config-model/src/test/derived/types/types.sd index 0590625e1c6..c908b648340 100644 --- a/config-model/src/test/derived/types/types.sd +++ b/config-model/src/test/derived/types/types.sd @@ -87,7 +87,7 @@ search types { field arrarr type array<array<array<string>>> {header} field maparr type array<map<string, string>> {header} - field complexarray type array< map<array<array<string>>, int> > {body} + field complexarray type array< map<int, array<array<string>>> > {body} struct mystruct { field bytearr type array<byte>{} diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java index 4f99922a422..6a1e5b207c6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java @@ -16,6 +16,9 @@ import java.util.List; import static org.junit.Assert.assertEquals; +/** + * @author lesters + */ public class RankingExpressionShadowingTestCase extends SearchDefinitionTestCase { @Test diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java new file mode 100644 index 00000000000..675e04191f8 --- /dev/null +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java @@ -0,0 +1,57 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.searchdefinition.processing; + +import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.parser.ParseException; +import org.junit.Test; + +/** + * @author lesters + */ +public class DisallowComplexMapAndWsetKeyTypesTestCase { + + @Test(expected = IllegalArgumentException.class) + public void requireThatComplexTypesForMapKeysFail() throws ParseException { + testFieldType("map<mystruct,string>"); + } + + @Test(expected = IllegalArgumentException.class) + public void requireThatComplexTypesForWsetFail() throws ParseException { + testFieldType("weightedset<mystruct>"); + } + + @Test(expected = IllegalArgumentException.class) + public void requireThatNestedComplexTypesForMapFail() throws ParseException { + testFieldType("array<map<mystruct,string>>"); + } + + @Test + public void requireThatNestedComplexValuesForMapSucceed() throws ParseException { + testFieldType("array<map<string,mystruct>>"); + } + + @Test(expected = IllegalArgumentException.class) + public void requireThatNestedComplexTypesForWsetFail() throws ParseException { + testFieldType("array<weightedset<mystruct>>"); + } + + @Test(expected = IllegalArgumentException.class) + public void requireThatDeepNestedComplexTypesForMapFail() throws ParseException { + testFieldType("map<string,map<mystruct,string>>"); + } + + private void testFieldType(String fieldType) throws ParseException { + RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); + SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + builder.importString( + "search test {\n" + + " document test { \n" + + " struct mystruct {}\n" + + " field a type " + fieldType + " {}\n" + + " }\n" + + "}\n"); + builder.build(); + } + +} |