use of com.yahoo.searchdefinition.document.Attribute in project vespa by vespa-engine.
the class AttributeListTestCase method testDeriving.
@Test
public void testDeriving() throws IOException, ParseException {
// Test attribute importing
Search search = SearchBuilder.buildFromFile("src/test/examples/simple.sd");
// Test attribute deriving
AttributeFields attributeFields = new AttributeFields(search);
Iterator attributes = attributeFields.attributeIterator();
Attribute attribute;
attribute = (Attribute) attributes.next();
assertEquals("popularity", attribute.getName());
assertEquals(Attribute.Type.INTEGER, attribute.getType());
assertEquals(Attribute.CollectionType.SINGLE, attribute.getCollectionType());
attribute = (Attribute) attributes.next();
assertEquals("measurement", attribute.getName());
assertEquals(Attribute.Type.INTEGER, attribute.getType());
assertEquals(Attribute.CollectionType.SINGLE, attribute.getCollectionType());
attribute = (Attribute) attributes.next();
assertEquals("smallattribute", attribute.getName());
assertEquals(Attribute.Type.BYTE, attribute.getType());
assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
attribute = (Attribute) attributes.next();
assertEquals("access", attribute.getName());
assertEquals(Attribute.Type.BYTE, attribute.getType());
assertEquals(Attribute.CollectionType.SINGLE, attribute.getCollectionType());
attribute = (Attribute) attributes.next();
assertEquals("category_arr", attribute.getName());
assertEquals(Attribute.Type.STRING, attribute.getType());
assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
attribute = (Attribute) attributes.next();
assertEquals("measurement_arr", attribute.getName());
assertEquals(Attribute.Type.INTEGER, attribute.getType());
assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
attribute = (Attribute) attributes.next();
assertEquals("popsiness", attribute.getName());
assertEquals(Attribute.Type.INTEGER, attribute.getType());
assertEquals(Attribute.CollectionType.SINGLE, attribute.getCollectionType());
assertTrue(!attributes.hasNext());
}
use of com.yahoo.searchdefinition.document.Attribute in project vespa by vespa-engine.
the class AttributeFields method deriveAttribute.
private void deriveAttribute(ImmutableSDField field, Attribute fieldAttribute) {
Attribute attribute = getAttribute(fieldAttribute.getName());
if (attribute == null) {
attributes.put(fieldAttribute.getName(), fieldAttribute);
attribute = getAttribute(fieldAttribute.getName());
}
Ranking ranking = field.getRanking();
if (ranking != null && ranking.isFilter()) {
attribute.setEnableBitVectors(true);
attribute.setEnableOnlyBitVector(true);
}
}
use of com.yahoo.searchdefinition.document.Attribute in project vespa by vespa-engine.
the class AttributeSettingsTestCase method requireThatFastAccessCanBeSet.
@Test
public void requireThatFastAccessCanBeSet() throws IOException, ParseException {
Search search = SearchBuilder.buildFromFile("src/test/examples/attributesettings.sd");
SDField field = (SDField) search.getDocument().getField("fast_access");
assertTrue(field.getAttributes().size() == 1);
Attribute attr = field.getAttributes().get(field.getName());
assertTrue(attr.isFastAccess());
}
use of com.yahoo.searchdefinition.document.Attribute in project vespa by vespa-engine.
the class PositionTestCase method assertPositionAttribute.
private static void assertPositionAttribute(Search search, String fieldName, Attribute.CollectionType type) {
Attribute attribute = search.getAttribute(PositionDataType.getZCurveFieldName(fieldName));
assertNotNull(attribute);
assertTrue(attribute.isPosition());
assertTrue(attribute.getCollectionType().equals(type));
assertTrue(attribute.getType().equals(Attribute.Type.LONG));
}
use of com.yahoo.searchdefinition.document.Attribute in project vespa by vespa-engine.
the class ImplicitSummaries method isValid.
// Returns whether this is valid. Warns if invalid and ignorable. Throws if not ignorable.
private boolean isValid(SummaryField summaryField, Search search, boolean validate) {
if (summaryField.getTransform() == SummaryTransform.DISTANCE || summaryField.getTransform() == SummaryTransform.POSITIONS) {
int sourceCount = summaryField.getSourceCount();
if (validate && sourceCount != 1) {
throw newProcessException(search.getName(), summaryField.getName(), "Expected 1 source field, got " + sourceCount + ".");
}
String sourceName = summaryField.getSingleSource();
if (validate && search.getAttribute(sourceName) == null) {
throw newProcessException(search.getName(), summaryField.getName(), "Summary source attribute '" + sourceName + "' not found.");
}
return true;
}
String fieldName = summaryField.getSourceField();
SDField sourceField = search.getConcreteField(fieldName);
if (validate && sourceField == null) {
throw newProcessException(search, summaryField, "Source field '" + fieldName + "' does not exist.");
}
if (!sourceField.doesSummarying() && !summaryField.getTransform().equals(SummaryTransform.ATTRIBUTE) && !summaryField.getTransform().equals(SummaryTransform.GEOPOS)) {
// Summary transform attribute may indicate that the ilscript was rewritten to remove summary
// by another search that uses this same field in inheritance.
deployLogger.log(Level.WARNING, "Ignoring " + summaryField + ": " + sourceField + " is not creating a summary value in its indexing statement");
return false;
}
if (summaryField.getTransform().isDynamic() && summaryField.getName().equals(sourceField.getName()) && sourceField.doesAttributing()) {
Attribute attribute = sourceField.getAttributes().get(sourceField.getName());
if (attribute != null) {
String destinations = "document summary 'default'";
if (summaryField.getDestinations().size() > 0) {
destinations = "document summaries " + summaryField.getDestinations();
}
deployLogger.log(Level.WARNING, "Will fetch the disk summary value of " + sourceField + " in " + destinations + " since this summary field uses a dynamic summary value (snippet/bolding): Dynamic summaries and bolding " + "is not supported with summary values fetched from in-memory attributes yet. If you want to see partial updates " + "to this attribute, remove any bolding and dynamic snippeting from this field");
// Note: The dynamic setting has already overridden the attribute map setting,
// so we do not need to actually do attribute.setSummary(false) here
// Also, we can not do this, since it makes it impossible to fetch this attribute
// in another summary
}
}
return true;
}
Aggregations