use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.
the class FieldOperationApplierForStructs method copyFields.
private void copyFields(SDDocumentType structType, SDDocumentType sdoc) {
// find all fields in OTHER types that have this type:
List<SDDocumentType> list = new ArrayList<>();
list.add(sdoc);
list.addAll(sdoc.getTypes());
for (SDDocumentType anyType : list) {
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(), field.isHeader(), 0);
field.populateWithStructMatching(sdoc, field.getName(), field.getDataType(), field.getMatching());
}
}
}
}
use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.
the class SearchDataTypeValidator method validate.
@Override
public void validate(VespaModel model, DeployState deployState) {
List<AbstractSearchCluster> clusters = model.getSearchClusters();
for (AbstractSearchCluster cluster : clusters) {
if (cluster.isStreaming()) {
continue;
}
for (AbstractSearchCluster.SearchDefinitionSpec spec : cluster.getLocalSDS()) {
SDDocumentType docType = spec.getSearchDefinition().getSearch().getDocument();
if (docType == null) {
continue;
}
validateDocument(cluster, spec.getSearchDefinition(), docType);
}
}
}
use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.
the class SearchDataTypeValidator method validateDocument.
private void validateDocument(AbstractSearchCluster cluster, SearchDefinition def, SDDocumentType doc) {
for (SDDocumentType child : doc.getTypes()) {
validateDocument(cluster, def, child);
}
for (Field field : doc.fieldSet()) {
DataType fieldType = field.getDataType();
disallowIndexingOfMaps(cluster, def, field);
if (!isSupportedInSearchClusters(fieldType)) {
throw new IllegalArgumentException("Field type '" + fieldType.getName() + "' is illegal for search " + "clusters (field '" + field.getName() + "' in definition '" + def.getName() + "' for cluster '" + cluster.getClusterName() + "').");
}
}
}
use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.
the class DocumentReferenceResolverTest method throws_user_friendly_exception_if_referenced_document_does_not_exist.
@Test
public void throws_user_friendly_exception_if_referenced_document_does_not_exist() {
// Create foo document with document reference to non-existing document bar
SDField fooRefToBarField = new SDField("bar_ref", ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create("bar")));
addAttributeAspect(fooRefToBarField);
Search fooSearch = new Search();
SDDocumentType fooDocument = new SDDocumentType("foo", fooSearch);
fooDocument.addField(fooRefToBarField);
fooSearch.addDocument(fooDocument);
DocumentReferenceResolver resolver = new DocumentReferenceResolver(singletonList(fooSearch));
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("The field 'bar_ref' is an invalid document reference. " + "Could not find document with 'bar' in any search definitions");
resolver.resolveReferences(fooDocument);
}
use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.
the class SDDocumentTypeTestCase method testSetGet.
// Verify that we can register and retrieve fields.
@Test
public void testSetGet() {
SDDocumentType docType = new SDDocumentType("testdoc");
docType.addField("Bongle", DataType.STRING);
docType.addField("nalle", DataType.INT);
assertNotNull(docType.getField("Bongle").getName(), "Bongle");
assertNull(docType.getField("bongle"));
}
Aggregations