Search in sources :

Example 16 with SummaryField

use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.

the class VsmSummary method doMapField.

/**
 * Don't include field in map if sources are the same as the struct sub fields for the SDField.
 * But do map if not all do summarying.
 * Don't map if not struct either.
 * @param summaryField a {@link SummaryField}
 */
private boolean doMapField(Search search, SummaryField summaryField) {
    SDField sdField = search.getConcreteField(summaryField.getName());
    SDDocumentType document = search.getDocument();
    if (sdField == null || ((document != null) && (document.getField(summaryField.getName()) == sdField))) {
        return true;
    }
    if (summaryField.getVsmCommand().equals(SummaryField.VsmCommand.FLATTENJUNIPER)) {
        return true;
    }
    if (!sdField.usesStructOrMap()) {
        return !(sdField.getName().equals(summaryField.getName()));
    }
    if (summaryField.getSourceCount() == sdField.getStructFields().size()) {
        for (SummaryField.Source source : summaryField.getSources()) {
            if (!sdField.getStructFields().contains(new SDField(search.getDocument(), source.getName(), sdField.getDataType()))) {
                // equals() uses just name
                return true;
            }
            if (sdField.getStructField(source.getName()) != null && !sdField.getStructField(source.getName()).doesSummarying()) {
                return true;
            }
        }
        // Don't map.
        return false;
    }
    return true;
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType)

Example 17 with SummaryField

use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.

the class IndexingScriptChangeMessageBuilder method checkSummaryTransform.

private void checkSummaryTransform(ChangeMessageBuilder builder) {
    for (SummaryField nextSummaryField : nextField.getSummaryFields()) {
        String fieldName = nextSummaryField.getName();
        SummaryField currentSummaryField = currentField.getSummaryField(fieldName);
        if (currentSummaryField != null) {
            SummaryTransform currentTransform = currentSummaryField.getTransform();
            SummaryTransform nextTransform = nextSummaryField.getTransform();
            if (!currentSummaryField.getTransform().equals(nextSummaryField.getTransform())) {
                builder.addChange("summary field '" + fieldName + "' transform", currentTransform.getName(), nextTransform.getName());
            }
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) SummaryTransform(com.yahoo.vespa.documentmodel.SummaryTransform)

Example 18 with SummaryField

use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.

the class IndexingScriptRewriterTestCase method createSummaryField.

private static SummaryField createSummaryField(SDField field, String name, boolean dynamic) {
    SummaryField summaryField = new SummaryField(name, field.getDataType());
    if (dynamic) {
        summaryField.setTransform(SummaryTransform.DYNAMICTEASER);
    }
    summaryField.addDestination("default");
    summaryField.addSource(field.getName());
    return summaryField;
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField)

Example 19 with SummaryField

use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.

the class PositionTestCase method requireThatSummaryAloneDoesNotCreateZCurve.

@Test
public void requireThatSummaryAloneDoesNotCreateZCurve() throws Exception {
    Search search = SearchBuilder.buildFromFile("src/test/examples/position_summary.sd");
    assertNull(search.getAttribute("pos"));
    assertNull(search.getAttribute("pos.x"));
    assertNull(search.getAttribute("pos.y"));
    assertNull(search.getAttribute("pos.zcurve"));
    SummaryField summary = search.getSummaryField("pos");
    assertNotNull(summary);
    assertEquals(2, summary.getSourceCount());
    Iterator<SummaryField.Source> it = summary.getSources().iterator();
    assertEquals("pos.x", it.next().getName());
    assertEquals("pos.y", it.next().getName());
    assertEquals(SummaryTransform.NONE, summary.getTransform());
    assertNull(search.getSummaryField("pos_ext.distance"));
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 20 with SummaryField

use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.

the class PositionTestCase method assertSummaryField.

private static void assertSummaryField(Search search, String fieldName, String sourceName, DataType dataType, SummaryTransform transform) {
    SummaryField summary = search.getSummaryField(fieldName);
    assertNotNull(summary);
    assertEquals(1, summary.getSourceCount());
    assertEquals(sourceName, summary.getSingleSource());
    assertEquals(dataType, summary.getDataType());
    assertEquals(transform, summary.getTransform());
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField)

Aggregations

SummaryField (com.yahoo.vespa.documentmodel.SummaryField)26 DocumentSummary (com.yahoo.vespa.documentmodel.DocumentSummary)10 Attribute (com.yahoo.searchdefinition.document.Attribute)3 SDField (com.yahoo.searchdefinition.document.SDField)3 Index (com.yahoo.searchdefinition.Index)2 Search (com.yahoo.searchdefinition.Search)2 SummaryTransform (com.yahoo.vespa.documentmodel.SummaryTransform)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 Pair (com.yahoo.collections.Pair)1 DataType (com.yahoo.document.DataType)1 Field (com.yahoo.document.Field)1 TensorDataType (com.yahoo.document.TensorDataType)1 BooleanIndexDefinition (com.yahoo.searchdefinition.document.BooleanIndexDefinition)1 ImmutableSDField (com.yahoo.searchdefinition.document.ImmutableSDField)1 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)1 Source (com.yahoo.vespa.documentmodel.SummaryField.Source)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1