use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class SDFieldTestCase method testIdSettingConflict.
@Test
public void testIdSettingConflict() {
SDDocumentType doc = new SDDocumentType("testdoc");
SDField one = (SDField) doc.addField("one", DataType.STRING, false, 60);
SDField two = (SDField) doc.addField("two", DataType.STRING, false, 61);
try {
SDField three = (SDField) doc.addField("three", DataType.STRING, false, 60);
fail("Allowed to set duplicate id");
} catch (IllegalArgumentException e) {
// Success
}
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class SummaryMapTestCase method testPositionDeriving.
@Test
public void testPositionDeriving() throws IOException, ParseException {
Search search = new Search("store", null);
SDDocumentType document = new SDDocumentType("store");
search.addDocument(document);
String fieldName = "location";
SDField field = document.addField(fieldName, PositionDataType.INSTANCE);
field.parseIndexingScript("{ attribute | summary }");
Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
SummaryMap summaryMap = new SummaryMap(search, new Summaries(search, new BaseDeployLogger()));
Iterator transforms = summaryMap.resultTransformIterator();
FieldResultTransform transform = (FieldResultTransform) transforms.next();
assertEquals(fieldName, transform.getFieldName());
assertEquals(SummaryTransform.GEOPOS, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals(PositionDataType.getPositionSummaryFieldName(fieldName), transform.getFieldName());
assertEquals(SummaryTransform.POSITIONS, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals(PositionDataType.getDistanceSummaryFieldName(fieldName), transform.getFieldName());
assertEquals(SummaryTransform.DISTANCE, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals("rankfeatures", transform.getFieldName());
assertEquals(SummaryTransform.RANKFEATURES, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals("summaryfeatures", transform.getFieldName());
assertEquals(SummaryTransform.SUMMARYFEATURES, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals("location_zcurve", transform.getFieldName());
assertEquals(SummaryTransform.ATTRIBUTE, transform.getTransform());
assertTrue(!transforms.hasNext());
SummarymapConfig.Builder scb = new SummarymapConfig.Builder();
summaryMap.getConfig(scb);
SummarymapConfig c = new SummarymapConfig(scb);
assertEquals(-1, c.defaultoutputclass());
assertEquals(c.override().size(), 6);
assertEquals(c.override(0).field(), fieldName);
assertEquals(c.override(0).command(), "geopos");
assertEquals(c.override(0).arguments(), PositionDataType.getZCurveFieldName(fieldName));
assertEquals(c.override(1).field(), PositionDataType.getPositionSummaryFieldName(fieldName));
assertEquals(c.override(1).command(), "positions");
assertEquals(c.override(1).arguments(), PositionDataType.getZCurveFieldName(fieldName));
assertEquals(c.override(2).field(), PositionDataType.getDistanceSummaryFieldName(fieldName));
assertEquals(c.override(2).command(), "absdist");
assertEquals(c.override(2).arguments(), PositionDataType.getZCurveFieldName(fieldName));
assertEquals(c.override(3).field(), "rankfeatures");
assertEquals(c.override(3).command(), "rankfeatures");
assertEquals(c.override(3).arguments(), "");
assertEquals(c.override(4).field(), "summaryfeatures");
assertEquals(c.override(4).command(), "summaryfeatures");
assertEquals(c.override(4).arguments(), "");
assertEquals(c.override(5).field(), "location_zcurve");
assertEquals(c.override(5).command(), "attribute");
assertEquals(c.override(5).arguments(), "location_zcurve");
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class EmptyRankProfileTestCase method testDeriving.
@Test
public void testDeriving() {
Search search = new Search("test", null);
RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
SDDocumentType doc = new SDDocumentType("test");
search.addDocument(doc);
doc.addField(new SDField("a", DataType.STRING));
SDField field = new SDField("b", DataType.STRING);
field.setLiteralBoost(500);
doc.addField(field);
doc.addField(new SDField("c", DataType.STRING));
search = SearchBuilder.buildFromRawSearch(search, rankProfileRegistry, new QueryProfileRegistry());
new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class IdTestCase method testExplicitUpperCaseIdField.
@Test
@SuppressWarnings({ "deprecation" })
public void testExplicitUpperCaseIdField() {
Search search = new Search("test", null);
SDDocumentType document = new SDDocumentType("test");
search.addDocument(document);
SDField uri = new SDField("URI", DataType.URI);
uri.parseIndexingScript("{ summary | index }");
document.addField(uri);
Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
assertNull(document.getField("uri"));
assertNull(document.getField("Uri"));
assertNotNull(document.getField("URI"));
}
use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.
the class DocumentGraphValidatorTest method createDocumentReference.
private static void createDocumentReference(Search from, Search to, String refFieldName) {
SDField refField = new TemporarySDField(refFieldName, ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create(to.getName())));
SDDocumentType fromDocument = from.getDocument();
fromDocument.addField(refField);
Map<String, DocumentReference> originalMap = fromDocument.getDocumentReferences().get().referenceMap();
HashMap<String, DocumentReference> modifiedMap = new HashMap<>(originalMap);
modifiedMap.put(refFieldName, new DocumentReference(refField, to));
fromDocument.setDocumentReferences(new DocumentReferences(modifiedMap));
}
Aggregations