Search in sources :

Example 1 with SubstituteString

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

the class QueryProfiles method addVariantFieldChildren.

private void addVariantFieldChildren(QueryProfilesConfig.Queryprofile.Queryprofilevariant.Builder qpB, QueryProfile profile, String namePrefix) {
    List<Map.Entry<String, Object>> content = new ArrayList<>(profile.declaredContent().entrySet());
    Collections.sort(content, new MapEntryKeyComparator());
    if (profile.getValue() != null) {
        // Add "prefix with dot removed"=value:
        QueryProfilesConfig.Queryprofile.Queryprofilevariant.Property.Builder propB = new QueryProfilesConfig.Queryprofile.Queryprofilevariant.Property.Builder();
        String fullName = namePrefix.substring(0, namePrefix.length() - 1);
        Object value = profile.getValue();
        if (value instanceof SubstituteString)
            // Send only types understood by configBuilder downwards
            value = value.toString();
        propB.name(fullName);
        if (value != null)
            propB.value(value.toString());
        qpB.property(propB);
    }
    for (Map.Entry<String, Object> field : content) {
        addVariantField(qpB, field, namePrefix);
    }
}
Also used : QueryProfilesConfig(com.yahoo.search.query.profile.config.QueryProfilesConfig) SubstituteString(com.yahoo.search.query.profile.SubstituteString) SubstituteString(com.yahoo.search.query.profile.SubstituteString) Entry(java.util.Map.Entry)

Example 2 with SubstituteString

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

the class QueryProfiles method addFieldChildren.

private void addFieldChildren(QueryProfilesConfig.Queryprofile.Builder qpB, QueryProfile profile, String namePrefix) {
    List<Map.Entry<String, Object>> content = new ArrayList<>(profile.declaredContent().entrySet());
    Collections.sort(content, new MapEntryKeyComparator());
    if (profile.getValue() != null) {
        // Add "prefix with dot removed"=value:
        QueryProfilesConfig.Queryprofile.Property.Builder propB = new QueryProfilesConfig.Queryprofile.Property.Builder();
        String fullName = namePrefix.substring(0, namePrefix.length() - 1);
        Object value = profile.getValue();
        if (value instanceof SubstituteString)
            // Send only types understood by configBuilder downwards
            value = value.toString();
        propB.name(fullName);
        if (value != null)
            propB.value(value.toString());
        qpB.property(propB);
    }
    for (Map.Entry<String, Object> field : content) {
        addField(qpB, profile, field, namePrefix);
    }
}
Also used : QueryProfilesConfig(com.yahoo.search.query.profile.config.QueryProfilesConfig) SubstituteString(com.yahoo.search.query.profile.SubstituteString) SubstituteString(com.yahoo.search.query.profile.SubstituteString) Entry(java.util.Map.Entry)

Aggregations

SubstituteString (com.yahoo.search.query.profile.SubstituteString)2 QueryProfilesConfig (com.yahoo.search.query.profile.config.QueryProfilesConfig)2 Entry (java.util.Map.Entry)2