Search in sources :

Example 31 with SDField

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
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Test(org.junit.Test)

Example 32 with SDField

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");
}
Also used : SummarymapConfig(com.yahoo.vespa.config.search.SummarymapConfig) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 33 with SDField

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());
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 34 with SDField

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"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) Test(org.junit.Test)

Example 35 with SDField

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));
}
Also used : TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) HashMap(java.util.HashMap) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField)

Aggregations

SDField (com.yahoo.searchdefinition.document.SDField)85 Test (org.junit.Test)33 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)22 Search (com.yahoo.searchdefinition.Search)15 Attribute (com.yahoo.searchdefinition.document.Attribute)11 Index (com.yahoo.searchdefinition.Index)7 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 ArrayList (java.util.ArrayList)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 Field (com.yahoo.document.Field)6 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)6 ScriptExpression (com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)6 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)5 ImmutableSDField (com.yahoo.searchdefinition.document.ImmutableSDField)5 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)5 ArrayDataType (com.yahoo.document.ArrayDataType)4 DataType (com.yahoo.document.DataType)4 DocumentReference (com.yahoo.searchdefinition.DocumentReference)4 RankProfile (com.yahoo.searchdefinition.RankProfile)4 TemporarySDField (com.yahoo.searchdefinition.document.TemporarySDField)4