Search in sources :

Example 1 with FieldType

use of com.yahoo.search.query.profile.types.FieldType in project vespa by vespa-engine.

the class RankProfileTypeSettingsProcessor method processFieldDescription.

private void processFieldDescription(FieldDescription fieldDescription) {
    String fieldName = fieldDescription.getName();
    FieldType fieldType = fieldDescription.getType();
    if (fieldType instanceof TensorFieldType) {
        TensorFieldType tensorFieldType = (TensorFieldType) fieldType;
        FeatureNames.argumentOf(fieldName).ifPresent(argument -> addQueryFeatureTypeToRankProfiles(argument, tensorFieldType.asTensorType().toString()));
    }
}
Also used : TensorFieldType(com.yahoo.search.query.profile.types.TensorFieldType) FieldType(com.yahoo.search.query.profile.types.FieldType) TensorFieldType(com.yahoo.search.query.profile.types.TensorFieldType)

Example 2 with FieldType

use of com.yahoo.search.query.profile.types.FieldType in project vespa by vespa-engine.

the class QueryProfileXMLReader method readFieldDefinitions.

private void readFieldDefinitions(Element element, QueryProfileType type, QueryProfileTypeRegistry registry) {
    for (Element field : XML.getChildren(element, "field")) {
        String name = field.getAttribute("name");
        if (name == null || name.equals(""))
            throw new IllegalArgumentException("A field has no 'name' attribute");
        try {
            String fieldTypeName = field.getAttribute("type");
            if (fieldTypeName == null)
                throw new IllegalArgumentException("Field '" + field + "' has no 'type' attribute");
            FieldType fieldType = FieldType.fromString(fieldTypeName, registry);
            type.addField(new FieldDescription(name, fieldType, field.getAttribute("alias"), getBooleanAttribute("mandatory", false, field), getBooleanAttribute("overridable", true, field)), registry);
        } catch (RuntimeException e) {
            throw new IllegalArgumentException("Invalid field '" + name + "'", e);
        }
    }
}
Also used : Element(org.w3c.dom.Element) FieldDescription(com.yahoo.search.query.profile.types.FieldDescription) FieldType(com.yahoo.search.query.profile.types.FieldType)

Example 3 with FieldType

use of com.yahoo.search.query.profile.types.FieldType in project vespa by vespa-engine.

the class QueryProfileConfigurer method instantiateFieldDescription.

private static void instantiateFieldDescription(QueryProfilesConfig.Queryprofiletype.Field fieldConfig, QueryProfileType type, QueryProfileTypeRegistry registry) {
    try {
        FieldType fieldType = FieldType.fromString(fieldConfig.type(), registry);
        FieldDescription field = new FieldDescription(fieldConfig.name(), fieldType, fieldConfig.alias(), fieldConfig.mandatory(), fieldConfig.overridable());
        type.addField(field, registry);
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException("Invalid field '" + fieldConfig.name() + "' in " + type, e);
    }
}
Also used : FieldDescription(com.yahoo.search.query.profile.types.FieldDescription) FieldType(com.yahoo.search.query.profile.types.FieldType)

Aggregations

FieldType (com.yahoo.search.query.profile.types.FieldType)3 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)2 TensorFieldType (com.yahoo.search.query.profile.types.TensorFieldType)1 Element (org.w3c.dom.Element)1