Search in sources :

Example 6 with Search

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

the class ImplicitSearchFieldsTestCase method testRequireThatUntransformedSummaryFieldsAreIgnored.

@Test
public void testRequireThatUntransformedSummaryFieldsAreIgnored() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/untransformedsummaryfields.sd");
    assertNotNull(search);
    SDDocumentType docType = search.getDocument();
    assertNotNull(docType);
    assertNotNull(docType.getField("rankfeatures"));
    assertNotNull(docType.getField("summaryfeatures"));
    assertNotNull(docType.getField("foo"));
    assertNotNull(docType.getField("bar"));
    assertNotNull(docType.getField("baz"));
    assertEquals(5, docType.getFieldCount());
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 7 with Search

use of com.yahoo.searchdefinition.Search 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 8 with Search

use of com.yahoo.searchdefinition.Search 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 9 with Search

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

the class AttributeListTestCase method testDeriving.

@Test
public void testDeriving() throws IOException, ParseException {
    // Test attribute importing
    Search search = SearchBuilder.buildFromFile("src/test/examples/simple.sd");
    // Test attribute deriving
    AttributeFields attributeFields = new AttributeFields(search);
    Iterator attributes = attributeFields.attributeIterator();
    Attribute attribute;
    attribute = (Attribute) attributes.next();
    assertEquals("popularity", attribute.getName());
    assertEquals(Attribute.Type.INTEGER, attribute.getType());
    assertEquals(Attribute.CollectionType.SINGLE, attribute.getCollectionType());
    attribute = (Attribute) attributes.next();
    assertEquals("measurement", attribute.getName());
    assertEquals(Attribute.Type.INTEGER, attribute.getType());
    assertEquals(Attribute.CollectionType.SINGLE, attribute.getCollectionType());
    attribute = (Attribute) attributes.next();
    assertEquals("smallattribute", attribute.getName());
    assertEquals(Attribute.Type.BYTE, attribute.getType());
    assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
    attribute = (Attribute) attributes.next();
    assertEquals("access", attribute.getName());
    assertEquals(Attribute.Type.BYTE, attribute.getType());
    assertEquals(Attribute.CollectionType.SINGLE, attribute.getCollectionType());
    attribute = (Attribute) attributes.next();
    assertEquals("category_arr", attribute.getName());
    assertEquals(Attribute.Type.STRING, attribute.getType());
    assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
    attribute = (Attribute) attributes.next();
    assertEquals("measurement_arr", attribute.getName());
    assertEquals(Attribute.Type.INTEGER, attribute.getType());
    assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
    attribute = (Attribute) attributes.next();
    assertEquals("popsiness", attribute.getName());
    assertEquals(Attribute.Type.INTEGER, attribute.getType());
    assertEquals(Attribute.CollectionType.SINGLE, attribute.getCollectionType());
    assertTrue(!attributes.hasNext());
}
Also used : Attribute(com.yahoo.searchdefinition.document.Attribute) Search(com.yahoo.searchdefinition.Search) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 10 with Search

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

the class CasingTestCase method testCasing.

@Test
public void testCasing() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/casing.sd");
    assertEquals(search.getIndex("color").getName(), "color");
    assertEquals(search.getIndex("Foo").getName(), "Foo");
    assertEquals(search.getIndex("Price").getName(), "Price");
    assertEquals(search.getAttribute("artist").getName(), "artist");
    assertEquals(search.getAttribute("Drummer").getName(), "Drummer");
    assertEquals(search.getAttribute("guitarist").getName(), "guitarist");
    assertEquals(search.getAttribute("title").getName(), "title");
    assertEquals(search.getAttribute("Trumpetist").getName(), "Trumpetist");
    assertEquals(search.getAttribute("Saxophonist").getName(), "Saxophonist");
    assertEquals(search.getAttribute("TenorSaxophonist").getName(), "TenorSaxophonist");
    assertEquals(search.getAttribute("Flutist").getName(), "Flutist");
}
Also used : Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Aggregations

Search (com.yahoo.searchdefinition.Search)62 Test (org.junit.Test)47 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)21 SDField (com.yahoo.searchdefinition.document.SDField)15 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)13 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)12 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)8 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)8 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)6 File (java.io.File)5 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)4 RankProfile (com.yahoo.searchdefinition.RankProfile)3 Field (com.yahoo.document.Field)2 StructDataType (com.yahoo.document.StructDataType)2 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)2 DocumentReference (com.yahoo.searchdefinition.DocumentReference)2 Index (com.yahoo.searchdefinition.Index)2 UnprocessingSearchBuilder (com.yahoo.searchdefinition.UnprocessingSearchBuilder)2 Attribute (com.yahoo.searchdefinition.document.Attribute)2 ImportedField (com.yahoo.searchdefinition.document.ImportedField)2