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;
}
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());
}
}
}
}
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;
}
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"));
}
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());
}
Aggregations