summaryrefslogtreecommitdiffstats
path: root/config-model/src
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@broadpark.no>2019-01-10 15:33:47 +0100
committerTor Egge <Tor.Egge@broadpark.no>2019-01-11 11:18:03 +0100
commit714931304b90a3438c4b048f5b4f94119dac2b23 (patch)
treed4abe5a03366e85274bb3179a976d0405d419c5f /config-model/src
parent0719167b1ebdc03e79156dafded27edee3daa852 (diff)
Stop flattening imported fields.
Diffstat (limited to 'config-model/src')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java12
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/ImportedFields.java38
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java16
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/document/ImportedFields.java5
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFields.java18
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFields.java13
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolver.java30
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSource.java1
-rw-r--r--config-model/src/test/derived/imported_position_field_summary/index-info.cfg16
-rw-r--r--config-model/src/test/derived/imported_struct_fields/index-info.cfg144
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java2
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java27
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java2
13 files changed, 177 insertions, 147 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java
index 9ea17dab2ba..76dff404568 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java
@@ -53,9 +53,7 @@ public class AttributeFields extends Derived implements AttributesConfig.Produce
if (unsupportedFieldType(field)) {
return; // Ignore complex struct and map fields for indexed search (only supported for streaming search)
}
- if (field.isImportedField()) {
- deriveImportedAttributes(field);
- } else if (isArrayOfSimpleStruct(field)) {
+ if (isArrayOfSimpleStruct(field)) {
deriveArrayOfSimpleStruct(field);
} else if (isMapOfSimpleStruct(field)) {
deriveMapOfSimpleStruct(field);
@@ -84,6 +82,10 @@ public class AttributeFields extends Derived implements AttributesConfig.Produce
/** Derives one attribute. TODO: Support non-default named attributes */
private void deriveAttributes(ImmutableSDField field) {
+ if (field.isImportedField()) {
+ deriveImportedAttributes(field);
+ return;
+ }
for (Attribute fieldAttribute : field.getAttributes().values()) {
deriveAttribute(field, fieldAttribute);
}
@@ -125,6 +127,10 @@ public class AttributeFields extends Derived implements AttributesConfig.Produce
}
private void deriveAttributeAsArrayType(ImmutableSDField field) {
+ if (field.isImportedField()) {
+ deriveImportedAttributes(field);
+ return;
+ }
Attribute attribute = field.getAttributes().get(field.getName());
if (attribute != null) {
attributes.put(attribute.getName(), attribute.convertToArray());
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/ImportedFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/ImportedFields.java
index 97faf6cabd6..b44522e9771 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/ImportedFields.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/ImportedFields.java
@@ -1,14 +1,21 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.derived;
+import com.yahoo.document.DataType;
+import com.yahoo.document.PositionDataType;
import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.document.Attribute;
import com.yahoo.searchdefinition.document.ImmutableSDField;
+import com.yahoo.searchdefinition.document.ImportedComplexField;
import com.yahoo.searchdefinition.document.ImportedField;
import com.yahoo.vespa.config.search.ImportedFieldsConfig;
import java.util.Optional;
+import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isArrayOfSimpleStruct;
+import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isMapOfPrimitiveType;
+import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isMapOfSimpleStruct;
+
/**
* This class derives imported fields from search definition and produces imported-fields.cfg as needed by the search backend.
*
@@ -44,6 +51,37 @@ public class ImportedFields extends Derived implements ImportedFieldsConfig.Prod
}
private static void considerField(ImportedFieldsConfig.Builder builder, ImportedField field) {
+ if (field instanceof ImportedComplexField) {
+ considerComplexField(builder, (ImportedComplexField) field);
+ } else {
+ considerSimpleField(builder, field);
+ }
+ }
+
+ private static void considerComplexField(ImportedFieldsConfig.Builder builder, ImportedComplexField field) {
+ ImmutableSDField targetField = field.targetField();
+ if (targetField.getDataType().equals(PositionDataType.INSTANCE) ||
+ targetField.getDataType().equals(DataType.getArray(PositionDataType.INSTANCE))) {
+
+ } else if (isArrayOfSimpleStruct(targetField)) {
+ considerNestedFields(builder, field);
+ } else if (isMapOfSimpleStruct(targetField)) {
+ considerSimpleField(builder, field.getNestedField("key"));
+ considerNestedFields(builder, field.getNestedField("value"));
+ } else if (isMapOfPrimitiveType(targetField)) {
+ considerSimpleField(builder, field.getNestedField("key"));
+ considerSimpleField(builder, field.getNestedField("value"));
+ }
+ }
+
+ private static void considerNestedFields(ImportedFieldsConfig.Builder builder, ImportedField field) {
+ if (field instanceof ImportedComplexField) {
+ ImportedComplexField complexField = (ImportedComplexField) field;
+ complexField.getNestedFields().forEach(nestedField -> considerSimpleField(builder, nestedField));
+ }
+ }
+
+ private static void considerSimpleField(ImportedFieldsConfig.Builder builder, ImportedField field) {
ImmutableSDField targetField = field.targetField();
String targetFieldName = targetField.getName();
if (!isNestedFieldName(targetFieldName)) {
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 d658b6b425a..1e4a4a2a5d2 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
@@ -74,9 +74,6 @@ 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
@@ -86,19 +83,6 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer {
}
}
- private void deriveImportedComplexField(ImportedField field) {
- String fieldName = field.fieldName();
- if (isPositionField(field.targetField())) {
- addIndexCommand(fieldName, CMD_DEFAULT_POSITION);
- if (isPositionArrayField(field.targetField())) {
- addIndexCommand(fieldName, CMD_MULTIVALUE);
- }
- } else {
- 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/main/java/com/yahoo/searchdefinition/document/ImportedFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImportedFields.java
index 7c67fc422d4..2192a7e7bb1 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImportedFields.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImportedFields.java
@@ -12,15 +12,12 @@ import java.util.Map;
public class ImportedFields {
private final Map<String, ImportedField> fields;
- private final Map<String, ImportedField> complexFields;
- public ImportedFields(Map<String, ImportedField> fields, Map<String, ImportedField> complexFields) {
+ public ImportedFields(Map<String, ImportedField> fields) {
this.fields = fields;
- this.complexFields = complexFields;
}
public Map<String, ImportedField> fields() {
return Collections.unmodifiableMap(fields);
}
- public Map<String, ImportedField> complexFields() { return Collections.unmodifiableMap(complexFields); }
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFields.java
index 6a1275a73d9..59dc4275e15 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFields.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFields.java
@@ -4,7 +4,9 @@ package com.yahoo.searchdefinition.processing;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.searchdefinition.RankProfileRegistry;
import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.document.ImmutableImportedComplexSDField;
import com.yahoo.searchdefinition.document.ImmutableSDField;
+import com.yahoo.searchdefinition.document.ImportedComplexField;
import com.yahoo.vespa.documentmodel.SummaryField;
import com.yahoo.vespa.documentmodel.SummaryTransform;
import com.yahoo.vespa.model.container.search.QueryProfiles;
@@ -30,19 +32,21 @@ public class AddAttributeTransformToSummaryOfImportedFields extends Processor {
@Override
public void process(boolean validate, boolean documentsOnly) {
search.allImportedFields()
- .flatMap(this::getSummaryFieldsForImportedField)
- .forEach(AddAttributeTransformToSummaryOfImportedFields::setAttributeTransform);
- search.importedFields().map(fields -> fields.complexFields().values().stream()).
- orElse(Stream.empty()).
- map(field -> field.asImmutableSDField()).
- flatMap(this::getSummaryFieldsForImportedField).
- forEach(AddAttributeTransformToSummaryOfImportedFields::setAttributeCombinerTransform);
+ .forEach(field -> setTransform(field));
}
private Stream<SummaryField> getSummaryFieldsForImportedField(ImmutableSDField importedField) {
return search.getSummaryFields(importedField).values().stream();
}
+ private void setTransform(ImmutableSDField field) {
+ if (field instanceof ImmutableImportedComplexSDField) {
+ getSummaryFieldsForImportedField(field).forEach(AddAttributeTransformToSummaryOfImportedFields::setAttributeCombinerTransform);
+ } else {
+ getSummaryFieldsForImportedField(field).forEach(AddAttributeTransformToSummaryOfImportedFields::setAttributeTransform);
+ }
+ }
+
private static void setAttributeTransform(SummaryField summaryField) {
if (summaryField.getTransform() == SummaryTransform.NONE) {
summaryField.setTransform(SummaryTransform.ATTRIBUTE);
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFields.java
index 9f8ac9230b8..e59fcdf3dd0 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFields.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFields.java
@@ -42,7 +42,7 @@ public class AdjustPositionSummaryFields extends Processor {
if (isPositionDataType(summaryField.getDataType())) {
String originalSource = summaryField.getSingleSource();
if (originalSource.indexOf('.') == -1) { // Eliminate summary fields with pos.x or pos.y as source
- ImmutableSDField sourceField = getSourceField(originalSource);
+ ImmutableSDField sourceField = search.getField(originalSource);
if (sourceField != null) {
String zCurve = null;
if (sourceField.getDataType().equals(summaryField.getDataType())) {
@@ -95,17 +95,6 @@ public class AdjustPositionSummaryFields extends Processor {
summary.add(oldField);
}
- private ImmutableSDField getSourceField(String name) {
- ImmutableSDField field = search.getField(name);
- if (field == null && search.importedFields().isPresent()) {
- ImportedField importedField = search.importedFields().get().complexFields().get(name);
- if (importedField != null) {
- field = importedField.asImmutableSDField();
- }
- }
- return field;
- }
-
private boolean hasPositionAttribute(String name) {
Attribute attribute = search.getAttribute(name);
if (attribute == null) {
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolver.java
index 04abc8a421a..d6c334ee80b 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolver.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolver.java
@@ -33,7 +33,6 @@ import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isM
public class ImportedFieldsResolver extends Processor {
private final Map<String, ImportedField> importedFields = new LinkedHashMap<>();
- private final Map<String, ImportedField> importedComplexFields = new LinkedHashMap<>();
private final Optional<DocumentReferences> references;
public ImportedFieldsResolver(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) {
@@ -44,7 +43,7 @@ public class ImportedFieldsResolver extends Processor {
@Override
public void process(boolean validate, boolean documentsOnly) {
search.temporaryImportedFields().get().fields().forEach((name, field) -> resolveImportedField(field, validate));
- search.setImportedFields(new ImportedFields(importedFields, importedComplexFields));
+ search.setImportedFields(new ImportedFields(importedFields));
}
private void resolveImportedField(TemporaryImportedField importedField, boolean validate) {
@@ -71,14 +70,14 @@ public class ImportedFieldsResolver extends Processor {
ImmutableSDField targetZCurveField = getTargetField(importedZCurveField, reference);
resolveImportedNormalField(importedZCurveField, reference, targetZCurveField, validate);
ImportedComplexField importedStructField = new ImportedComplexField(importedField.fieldName(), reference, targetField);
- registerImportedComplexField(importedStructField);
+ registerImportedField(importedField, null, importedStructField);
}
private void resolveImportedArrayOfStructField(TemporaryImportedField importedField, DocumentReference reference,
ImmutableSDField targetField, boolean validate) {
ImportedComplexField importedStructField = new ImportedComplexField(importedField.fieldName(), reference, targetField);
resolveImportedNestedStructField(importedField, reference, importedStructField, targetField, validate);
- registerImportedComplexField(importedStructField);
+ registerImportedField(importedField, null, importedStructField);
}
private void resolveImportedMapOfStructField(TemporaryImportedField importedField, DocumentReference reference,
@@ -88,22 +87,23 @@ public class ImportedFieldsResolver extends Processor {
importedMapField.addNestedField(importedStructField);
resolveImportedNestedField(importedField, reference, importedMapField, targetField.getStructField("key"), validate);
resolveImportedNestedStructField(importedField, reference, importedStructField, importedStructField.targetField(), validate);
- registerImportedComplexField(importedMapField);
+ registerImportedField(importedField, null, importedMapField);
}
private void makeImportedNormalField(TemporaryImportedField importedField, ImportedComplexField owner, String name, DocumentReference reference, ImmutableSDField targetField) {
- if (importedFields.get(name) != null) {
- fail(importedField, name, targetFieldAsString(targetField.getName(), reference) +": Field already imported");
- }
ImportedField importedSimpleField = new ImportedSimpleField(name, reference, targetField);
- importedFields.put(name, importedSimpleField);
- if (owner != null) {
- owner.addNestedField(importedSimpleField);
- }
+ registerImportedField(importedField, owner, importedSimpleField);
}
- private void registerImportedComplexField(ImportedComplexField importedComplexField) {
- importedComplexFields.put(importedComplexField.fieldName(), importedComplexField);;
+ private void registerImportedField(TemporaryImportedField temporaryImportedField, ImportedComplexField owner, ImportedField importedField) {
+ if (owner != null) {
+ owner.addNestedField(importedField);
+ } else {
+ if (importedFields.get(importedField.fieldName()) != null) {
+ fail(temporaryImportedField, importedField.fieldName(), targetFieldAsString(importedField.targetField().getName(), importedField.reference()) + ": Field already imported");
+ }
+ importedFields.put(importedField.fieldName(), importedField);
+ }
}
private static String makeImportedNestedFieldName(TemporaryImportedField importedField, ImmutableSDField targetNestedField) {
@@ -143,7 +143,7 @@ public class ImportedFieldsResolver extends Processor {
ImportedComplexField importedMapField = new ImportedComplexField(importedField.fieldName(), reference, targetField);
resolveImportedNestedField(importedField, reference, importedMapField, targetField.getStructField("key"), validate);
resolveImportedNestedField(importedField, reference, importedMapField, targetField.getStructField("value"), validate);
- registerImportedComplexField(importedMapField);
+ registerImportedField(importedField, null, importedMapField);
}
private void resolveImportedNormalField(TemporaryImportedField importedField, DocumentReference reference,
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSource.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSource.java
index 008b3182d8f..c87801685bb 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSource.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSource.java
@@ -51,7 +51,6 @@ public class SummaryFieldsMustHaveValidSource extends Processor {
return isDocumentField(source) ||
(isNotInThisSummaryClass(summary, source) && isSummaryField(source)) ||
(isInThisSummaryClass(summary, source) && !source.equals(summaryField.getName())) ||
- (search.importedFields().map(fields -> fields.complexFields().get(source) != null).orElse(false)) ||
(SummaryClass.DOCUMENT_ID_FIELD.equals(source));
}
diff --git a/config-model/src/test/derived/imported_position_field_summary/index-info.cfg b/config-model/src/test/derived/imported_position_field_summary/index-info.cfg
index c87553d6537..4c8dafdf59b 100644
--- a/config-model/src/test/derived/imported_position_field_summary/index-info.cfg
+++ b/config-model/src/test/derived/imported_position_field_summary/index-info.cfg
@@ -9,18 +9,6 @@ indexinfo[].command[].indexname "parent_ref"
indexinfo[].command[].command "attribute"
indexinfo[].command[].indexname "parent_ref"
indexinfo[].command[].command "word"
-indexinfo[].command[].indexname "my_pos.x"
-indexinfo[].command[].command "index"
-indexinfo[].command[].indexname "my_pos.x"
-indexinfo[].command[].command "numerical"
-indexinfo[].command[].indexname "my_pos.y"
-indexinfo[].command[].command "index"
-indexinfo[].command[].indexname "my_pos.y"
-indexinfo[].command[].command "numerical"
-indexinfo[].command[].indexname "my_pos"
-indexinfo[].command[].command "default-position"
-indexinfo[].command[].indexname "my_pos"
-indexinfo[].command[].command "index"
indexinfo[].command[].indexname "my_pos.distance"
indexinfo[].command[].command "index"
indexinfo[].command[].indexname "my_pos.distance"
@@ -41,3 +29,7 @@ indexinfo[].command[].indexname "my_pos_zcurve"
indexinfo[].command[].command "fast-search"
indexinfo[].command[].indexname "my_pos_zcurve"
indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "my_pos"
+indexinfo[].command[].command "default-position"
+indexinfo[].command[].indexname "my_pos"
+indexinfo[].command[].command "index"
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 b32b487fe0f..8d7f4d4bece 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
@@ -1,71 +1,73 @@
-indexinfo[0].name "child"
-indexinfo[0].command[0].indexname "sddocname"
-indexinfo[0].command[0].command "index"
-indexinfo[0].command[1].indexname "sddocname"
-indexinfo[0].command[1].command "word"
-indexinfo[0].command[2].indexname "parent_ref"
-indexinfo[0].command[2].command "index"
-indexinfo[0].command[3].indexname "parent_ref"
-indexinfo[0].command[3].command "attribute"
-indexinfo[0].command[4].indexname "parent_ref"
-indexinfo[0].command[4].command "word"
-indexinfo[0].command[5].indexname "documentid"
-indexinfo[0].command[5].command "index"
-indexinfo[0].command[6].indexname "rankfeatures"
-indexinfo[0].command[6].command "index"
-indexinfo[0].command[7].indexname "summaryfeatures"
-indexinfo[0].command[7].command "index"
-indexinfo[0].command[8].indexname "my_elem_array.name"
-indexinfo[0].command[8].command "index"
-indexinfo[0].command[9].indexname "my_elem_array.name"
-indexinfo[0].command[9].command "attribute"
-indexinfo[0].command[10].indexname "my_elem_array.name"
-indexinfo[0].command[10].command "fast-search"
-indexinfo[0].command[11].indexname "my_elem_array.weight"
-indexinfo[0].command[11].command "index"
-indexinfo[0].command[12].indexname "my_elem_array.weight"
-indexinfo[0].command[12].command "attribute"
-indexinfo[0].command[13].indexname "my_elem_array.weight"
-indexinfo[0].command[13].command "numerical"
-indexinfo[0].command[14].indexname "my_elem_map.key"
-indexinfo[0].command[14].command "index"
-indexinfo[0].command[15].indexname "my_elem_map.key"
-indexinfo[0].command[15].command "attribute"
-indexinfo[0].command[16].indexname "my_elem_map.key"
-indexinfo[0].command[16].command "fast-search"
-indexinfo[0].command[17].indexname "my_elem_map.value.name"
-indexinfo[0].command[17].command "index"
-indexinfo[0].command[18].indexname "my_elem_map.value.name"
-indexinfo[0].command[18].command "attribute"
-indexinfo[0].command[19].indexname "my_elem_map.value.name"
-indexinfo[0].command[19].command "fast-search"
-indexinfo[0].command[20].indexname "my_elem_map.value.weight"
-indexinfo[0].command[20].command "index"
-indexinfo[0].command[21].indexname "my_elem_map.value.weight"
-indexinfo[0].command[21].command "attribute"
-indexinfo[0].command[22].indexname "my_elem_map.value.weight"
-indexinfo[0].command[22].command "numerical"
-indexinfo[0].command[23].indexname "my_str_int_map.key"
-indexinfo[0].command[23].command "index"
-indexinfo[0].command[24].indexname "my_str_int_map.key"
-indexinfo[0].command[24].command "attribute"
-indexinfo[0].command[25].indexname "my_str_int_map.key"
-indexinfo[0].command[25].command "fast-search"
-indexinfo[0].command[26].indexname "my_str_int_map.value"
-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"
-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_str_int_map"
-indexinfo[0].command[33].command "multivalue"
-indexinfo[0].command[34].indexname "my_str_int_map"
-indexinfo[0].command[34].command "index" \ No newline at end of file
+indexinfo[].name "child"
+indexinfo[].command[].indexname "sddocname"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "sddocname"
+indexinfo[].command[].command "word"
+indexinfo[].command[].indexname "parent_ref"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "parent_ref"
+indexinfo[].command[].command "attribute"
+indexinfo[].command[].indexname "parent_ref"
+indexinfo[].command[].command "word"
+indexinfo[].command[].indexname "documentid"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "rankfeatures"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "summaryfeatures"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_elem_array.name"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_elem_array.name"
+indexinfo[].command[].command "attribute"
+indexinfo[].command[].indexname "my_elem_array.name"
+indexinfo[].command[].command "fast-search"
+indexinfo[].command[].indexname "my_elem_array.weight"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_elem_array.weight"
+indexinfo[].command[].command "attribute"
+indexinfo[].command[].indexname "my_elem_array.weight"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "my_elem_array"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_elem_array"
+indexinfo[].command[].command "multivalue"
+indexinfo[].command[].indexname "my_elem_map.value.name"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_elem_map.value.name"
+indexinfo[].command[].command "attribute"
+indexinfo[].command[].indexname "my_elem_map.value.name"
+indexinfo[].command[].command "fast-search"
+indexinfo[].command[].indexname "my_elem_map.value.weight"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_elem_map.value.weight"
+indexinfo[].command[].command "attribute"
+indexinfo[].command[].indexname "my_elem_map.value.weight"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "my_elem_map.value"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_elem_map.key"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_elem_map.key"
+indexinfo[].command[].command "attribute"
+indexinfo[].command[].indexname "my_elem_map.key"
+indexinfo[].command[].command "fast-search"
+indexinfo[].command[].indexname "my_elem_map"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_elem_map"
+indexinfo[].command[].command "multivalue"
+indexinfo[].command[].indexname "my_str_int_map.key"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_str_int_map.key"
+indexinfo[].command[].command "attribute"
+indexinfo[].command[].indexname "my_str_int_map.key"
+indexinfo[].command[].command "fast-search"
+indexinfo[].command[].indexname "my_str_int_map.value"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_str_int_map.value"
+indexinfo[].command[].command "attribute"
+indexinfo[].command[].indexname "my_str_int_map.value"
+indexinfo[].command[].command "numerical"
+indexinfo[].command[].indexname "my_str_int_map"
+indexinfo[].command[].command "index"
+indexinfo[].command[].indexname "my_str_int_map"
+indexinfo[].command[].command "multivalue"
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java
index d0c63826054..defaf565a8b 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java
@@ -55,7 +55,7 @@ public class AddAttributeTransformToSummaryOfImportedFieldsTest {
SDField targetField = new SDField("target_field", DataType.INT);
DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
ImportedField importedField = new ImportedSimpleField(fieldName, documentReference, targetField);
- return new ImportedFields(Collections.singletonMap(fieldName, importedField), Collections.emptyMap());
+ return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
private static DocumentSummary createDocumentSummary(String fieldName) {
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java
index 48b79dade1f..724c15c3ef4 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java
@@ -3,6 +3,7 @@ package com.yahoo.searchdefinition.processing;
import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.SearchBuilder;
+import com.yahoo.searchdefinition.document.ImportedComplexField;
import com.yahoo.searchdefinition.document.ImportedField;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Rule;
@@ -91,7 +92,7 @@ public class ImportedFieldsTestCase {
" import field parent_ref.elem_map as my_elem_map {}",
" import field parent_ref.str_int_map as my_str_int_map {}",
"}"));
- assertEquals(parentBuilder.countAttrs(), search.importedFields().get().fields().size());
+ assertEquals(3, search.importedFields().get().fields().size());
checkImportedField("my_elem_array.name", "parent_ref", "parent", "elem_array.name", search, parentBuilder.elem_array_name_attr);
checkImportedField("my_elem_array.weight", "parent_ref", "parent", "elem_array.weight", search, parentBuilder.elem_array_weight_attr);
checkImportedField("my_elem_map.key", "parent_ref", "parent", "elem_map.key", search, parentBuilder.elem_map_key_attr);
@@ -99,6 +100,9 @@ public class ImportedFieldsTestCase {
checkImportedField("my_elem_map.value.weight", "parent_ref", "parent", "elem_map.value.weight", search, parentBuilder.elem_map_value_weight_attr);
checkImportedField("my_str_int_map.key", "parent_ref", "parent", "str_int_map.key", search, parentBuilder.str_int_map_key_attr);
checkImportedField("my_str_int_map.value", "parent_ref", "parent", "str_int_map.value", search, parentBuilder.str_int_map_value_attr);
+ checkImportedField("my_elem_array", "parent_ref", "parent", "elem_array", search, true);
+ checkImportedField("my_elem_map", "parent_ref", "parent", "elem_map", search, true);
+ checkImportedField("my_str_int_map", "parent_ref", "parent", "str_int_map", search, true);
}
@Test
@@ -275,8 +279,9 @@ public class ImportedFieldsTestCase {
private static void checkPosImport(ParentPosSdBuilder parentBuilder, ChildPosSdBuilder childBuilder) throws ParseException {
Search search = buildChildSearch(parentBuilder.build(), childBuilder.build());
- assertEquals(1, search.importedFields().get().fields().size());
+ assertEquals(2, search.importedFields().get().fields().size());
assertSearchContainsImportedField("my_pos_zcurve", "parent_ref", "parent", "pos_zcurve", search);
+ assertSearchContainsImportedField("my_pos", "parent_ref", "parent", "pos", search);
}
@Test
@@ -291,8 +296,22 @@ public class ImportedFieldsTestCase {
checkPosImport(new ParentPosSdBuilder(), new ChildPosSdBuilder().import_pos_zcurve_before(true));
}
+ private static ImportedField getImportedField(String name, Search search) {
+ if (name.contains(".")) {
+ assertNull(search.importedFields().get().fields().get(name));
+ String superFieldName = name.substring(0,name.indexOf("."));
+ String subFieldName = name.substring(name.indexOf(".")+1);
+ ImportedField superField = search.importedFields().get().fields().get(superFieldName);
+ if (superField != null && superField instanceof ImportedComplexField) {
+ return ((ImportedComplexField)superField).getNestedField(subFieldName);
+ }
+ return null;
+ }
+ return search.importedFields().get().fields().get(name);
+ }
+
private static void assertSearchNotContainsImportedField(String fieldName, Search search) {
- ImportedField importedField = search.importedFields().get().fields().get(fieldName);
+ ImportedField importedField = getImportedField(fieldName, search);
assertNull(importedField);
}
@@ -301,7 +320,7 @@ public class ImportedFieldsTestCase {
String referenceDocType,
String targetFieldName,
Search search) {
- ImportedField importedField = search.importedFields().get().fields().get(fieldName);
+ ImportedField importedField = getImportedField(fieldName, search);
assertNotNull(importedField);
assertEquals(fieldName, importedField.fieldName());
assertEquals(referenceFieldName, importedField.reference().referenceField().getName());
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java
index ee3134ef627..cec313f98d8 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java
@@ -56,7 +56,7 @@ public class ValidateFieldTypesTest {
SDField targetField = new SDField("target_field", dataType);
DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
ImportedField importedField = new ImportedSimpleField(fieldName, documentReference, targetField);
- return new ImportedFields(Collections.singletonMap(fieldName, importedField), Collections.emptyMap());
+ return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
private static DocumentSummary createDocumentSummary(String fieldName, DataType dataType) {