Search in sources :

Example 56 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class SDDocumentTypeOrdererTestCase method testOrder.

@Test
public void testOrder() {
    List<SDDocumentType> types = new ArrayList<>();
    SDDocumentType a = new SDDocumentType("a");
    SDDocumentType b = new SDDocumentType("b");
    SDDocumentType c = new SDDocumentType("c");
    SDDocumentType d = new SDDocumentType("d");
    SDDocumentType e = new SDDocumentType("e");
    SDDocumentType f = new SDDocumentType("f");
    SDDocumentType g = new SDDocumentType("g");
    b.inherit(new TemporarySDDocumentType(new DataTypeName("a")));
    c.inherit(new TemporarySDDocumentType(new DataTypeName("b")));
    d.inherit(new TemporarySDDocumentType(new DataTypeName("e")));
    g.inherit(new TemporarySDDocumentType(new DataTypeName("e")));
    g.inherit(new TemporarySDDocumentType(new DataTypeName("c")));
    SDField aFieldTypeB = new TemporarySDField("atypeb", DataType.STRING);
    a.addField(aFieldTypeB);
    SDField bFieldTypeC = new TemporarySDField("btypec", DataType.STRING);
    b.addField(bFieldTypeC);
    SDField cFieldTypeG = new TemporarySDField("ctypeg", DataType.STRING);
    c.addField(cFieldTypeG);
    SDField gFieldTypeF = new TemporarySDField("gtypef", DataType.STRING);
    g.addField(gFieldTypeF);
    SDField fFieldTypeC = new TemporarySDField("ftypec", DataType.STRING);
    f.addField(fFieldTypeC);
    SDField dFieldTypeE = new TemporarySDField("dtypee", DataType.STRING);
    d.addField(dFieldTypeE);
    types.add(a);
    types.add(b);
    types.add(c);
    types.add(d);
    types.add(e);
    types.add(f);
    types.add(g);
    SDDocumentTypeOrderer app = new SDDocumentTypeOrderer(types, new BaseDeployLogger());
    app.process();
    assertEquals(7, app.processingOrder.size());
    assertEquals(a, app.processingOrder.get(0));
    assertEquals(b, app.processingOrder.get(1));
    assertEquals(c, app.processingOrder.get(2));
    assertEquals(e, app.processingOrder.get(3));
    assertEquals(d, app.processingOrder.get(4));
    assertEquals(f, app.processingOrder.get(5));
    assertEquals(g, app.processingOrder.get(6));
}
Also used : TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) ArrayList(java.util.ArrayList) DataTypeName(com.yahoo.document.DataTypeName) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) Test(org.junit.Test)

Example 57 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class StemmingSettingTestCase method testStemmingSettings.

@Test
public void testStemmingSettings() throws IOException, ParseException {
    Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/stemmingsetting.sd");
    SDField artist = (SDField) search.getDocument().getField("artist");
    assertEquals(Stemming.SHORTEST, artist.getStemming(search));
    SDField title = (SDField) search.getDocument().getField("title");
    assertEquals(Stemming.NONE, title.getStemming(search));
    SDField song = (SDField) search.getDocument().getField("song");
    assertEquals(Stemming.MULTIPLE, song.getStemming(search));
    SDField track = (SDField) search.getDocument().getField("track");
    assertEquals(Stemming.SHORTEST, track.getStemming(search));
    SDField backward = (SDField) search.getDocument().getField("backward");
    assertEquals(Stemming.SHORTEST, backward.getStemming(search));
    Index defaultIndex = search.getIndex("default");
    assertEquals(Stemming.SHORTEST, defaultIndex.getStemming());
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Test(org.junit.Test)

Example 58 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class VsmFieldsTestCase method reference_type_field_is_unsearchable.

@Test
public void reference_type_field_is_unsearchable() {
    Search search = new Search("test", MockApplicationPackage.createEmpty());
    search.addDocument(new SDDocumentType("test"));
    SDField refField = new TemporarySDField("ref_field", ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create("parent_type")));
    refField.parseIndexingScript("{ summary }");
    search.getDocument().addField(refField);
    VsmFields vsmFields = new VsmFields(search);
    VsmfieldsConfig.Builder cfgBuilder = new VsmfieldsConfig.Builder();
    vsmFields.getConfig(cfgBuilder);
    VsmfieldsConfig cfg = new VsmfieldsConfig(cfgBuilder);
    assertEquals(1, cfg.fieldspec().size());
    VsmfieldsConfig.Fieldspec fieldSpec = cfg.fieldspec().get(0);
    assertEquals("ref_field", fieldSpec.name());
    assertEquals(VsmfieldsConfig.Fieldspec.Searchmethod.NONE, fieldSpec.searchmethod());
}
Also used : TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) VsmfieldsConfig(com.yahoo.vespa.config.search.vsm.VsmfieldsConfig) Test(org.junit.Test)

Example 59 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class IndexingScriptRewriterTestCase method testDynamicSummaryRewriting.

@Test
public void testDynamicSummaryRewriting() {
    SDField field = createField("test", DataType.STRING, "{ summary }");
    field.addSummaryField(createDynamicSummaryField(field, "dyn"));
    assertIndexingScript("{ input test | tokenize normalize stem:\"SHORTEST\" | summary dyn; }", field);
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Test(org.junit.Test)

Example 60 with SDField

use of com.yahoo.searchdefinition.document.SDField in project vespa by vespa-engine.

the class IndexingScriptRewriterTestCase method createPredicateField.

private static SDField createPredicateField(String name, DataType type, String script, int arity, OptionalLong lower_bound, OptionalLong upper_bound) {
    SDField field = new SDField(null, name, type);
    field.parseIndexingScript(script);
    Index index = new Index("foo");
    index.setBooleanIndexDefiniton(new BooleanIndexDefinition(OptionalInt.of(arity), lower_bound, upper_bound, OptionalDouble.empty()));
    field.addIndex(index);
    return field;
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Index(com.yahoo.searchdefinition.Index) BooleanIndexDefinition(com.yahoo.searchdefinition.document.BooleanIndexDefinition)

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