Search in sources :

Example 1 with RankProfileRegistry

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

the class BoldingTestCase method testBoldingNonString.

@Test
public void testBoldingNonString() throws IOException, ParseException {
    try {
        Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/processing/boldnonstring.sd");
        new Bolding(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
        fail();
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("'bolding: on' for non-text field"));
    }
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) 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 2 with RankProfileRegistry

use of com.yahoo.searchdefinition.RankProfileRegistry 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 3 with RankProfileRegistry

use of com.yahoo.searchdefinition.RankProfileRegistry 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 4 with RankProfileRegistry

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

the class LiteralBoostTestCase method testLiteralBoost.

/**
 * Tests adding of literal boost constructs
 */
@Test
public void testLiteralBoost() {
    Search search = new Search("literalboost", null);
    RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
    SDDocumentType document = new SDDocumentType("literalboost");
    search.addDocument(document);
    SDField field1 = document.addField("a", DataType.STRING);
    field1.parseIndexingScript("{ index }");
    field1.setLiteralBoost(20);
    RankProfile other = new RankProfile("other", search, rankProfileRegistry);
    rankProfileRegistry.addRankProfile(other);
    other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333));
    Processing.process(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), true);
    DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
    // Check attribute fields
    // TODO: assert content
    derived.getAttributeFields();
    // Check il script addition
    assertIndexing(Arrays.asList("clear_state | guard { input a | tokenize normalize stem:\"SHORTEST\" | index a; }", "clear_state | guard { input a | tokenize | index a_literal; }"), search);
    // Check index info addition
    IndexInfo indexInfo = derived.getIndexInfo();
    assertTrue(indexInfo.hasCommand("a", "literal-boost"));
}
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) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RankProfile(com.yahoo.searchdefinition.RankProfile) Test(org.junit.Test)

Example 5 with RankProfileRegistry

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

the class IntegerIndex2AttributeTestCase method testIntegerIndex2Attribute.

@Test
public void testIntegerIndex2Attribute() throws IOException, ParseException {
    Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/integerindex2attribute.sd");
    search.process();
    new IntegerIndex2Attribute(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
    SDField f;
    f = search.getConcreteField("s1");
    assertTrue(f.getAttributes().isEmpty());
    assertTrue(f.existsIndex("s1"));
    f = search.getConcreteField("s2");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(f.existsIndex("s2"));
    f = search.getConcreteField("as1");
    assertTrue(f.getAttributes().isEmpty());
    assertTrue(f.existsIndex("as1"));
    f = search.getConcreteField("as2");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(f.existsIndex("as2"));
    f = search.getConcreteField("i1");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(!f.existsIndex("i1"));
    f = search.getConcreteField("i2");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(!f.existsIndex("i2"));
    f = search.getConcreteField("ai1");
    assertEquals(search.getConcreteField("ai1").getAttributes().size(), 1);
    assertTrue(!search.getConcreteField("ai1").existsIndex("ai1"));
    f = search.getConcreteField("ai2");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(!f.existsIndex("ai2"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) 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)

Aggregations

RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)16 Test (org.junit.Test)14 Search (com.yahoo.searchdefinition.Search)13 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)10 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)8 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)7 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)7 SDField (com.yahoo.searchdefinition.document.SDField)7 RankProfile (com.yahoo.searchdefinition.RankProfile)4 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)4 Pair (com.yahoo.collections.Pair)1 AttributeFields (com.yahoo.searchdefinition.derived.AttributeFields)1 RawRankProfile (com.yahoo.searchdefinition.derived.RawRankProfile)1