Search in sources :

Example 11 with RankProfileRegistry

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

the class LiteralBoostTestCase method testTwoLiteralBoostFields.

/**
 * Tests literal boosts in two fields going to the same index
 */
@Test
public void testTwoLiteralBoostFields() {
    Search search = new Search("msb", null);
    RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
    SDDocumentType document = new SDDocumentType("msb");
    search.addDocument(document);
    SDField field1 = document.addField("title", DataType.STRING);
    field1.parseIndexingScript("{ summary | index }");
    field1.setLiteralBoost(20);
    SDField field2 = document.addField("body", DataType.STRING);
    field2.parseIndexingScript("{ summary | index }");
    field2.setLiteralBoost(20);
    search = SearchBuilder.buildFromRawSearch(search, rankProfileRegistry, new QueryProfileRegistry());
    new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
    assertIndexing(Arrays.asList("clear_state | guard { input title | tokenize normalize stem:\"SHORTEST\" | summary title | index title; }", "clear_state | guard { input body | tokenize normalize stem:\"SHORTEST\" | summary body | index body; }", "clear_state | guard { input title | tokenize | index title_literal; }", "clear_state | guard { input body | tokenize | index body_literal; }"), search);
}
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 12 with RankProfileRegistry

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

the class LiteralBoostTestCase method testNonDefaultRankLiteralBoost.

/**
 * Tests adding a literal boost in a non-default rank profile only
 */
@Test
public void testNonDefaultRankLiteralBoost() {
    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 }");
    RankProfile other = new RankProfile("other", search, rankProfileRegistry);
    rankProfileRegistry.addRankProfile(other);
    other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333));
    search = SearchBuilder.buildFromRawSearch(search, rankProfileRegistry, new QueryProfileRegistry());
    DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
    // 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) Search(com.yahoo.searchdefinition.Search) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RankProfile(com.yahoo.searchdefinition.RankProfile) Test(org.junit.Test)

Example 13 with RankProfileRegistry

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

the class TypeConversionTestCase method testExactStringToStringTypeConversion.

/**
 * Tests that exact-string stuff is not spilled over to the default index
 */
@Test
public void testExactStringToStringTypeConversion() {
    Search search = new Search("test", null);
    RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
    SDDocumentType document = new SDDocumentType("test");
    search.addDocument(document);
    SDField a = new SDField("a", DataType.STRING);
    a.parseIndexingScript("{ index }");
    document.addField(a);
    Processing.process(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), true);
    DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
    IndexInfo indexInfo = derived.getIndexInfo();
    assertFalse(indexInfo.hasCommand("default", "compact-to-term"));
}
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) Test(org.junit.Test)

Example 14 with RankProfileRegistry

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

the class RankPropertyVariablesTestCase method testRankPropVariables.

@Test
public void testRankPropVariables() throws IOException, ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    Search search = SearchBuilder.buildFromFile("src/test/examples/rankpropvars.sd", new BaseDeployLogger(), rankProfileRegistry, new QueryProfileRegistry());
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar1", "foo");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvar_2", "bar");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "other").getRankProperties(), "$testvarOne23", "baz");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$Testvar1", "1");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$Testvar_4", "4");
    assertRankPropEquals(rankProfileRegistry.getRankProfile(search, "another").getRankProperties(), "$testvarFour23", "234234.234");
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 15 with RankProfileRegistry

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

the class AttributePropertiesTestCase method testInvalidAttributeProperties.

@Test
public void testInvalidAttributeProperties() throws IOException, ParseException {
    try {
        Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/attributeproperties1.sd");
        new AttributeProperties(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
        fail("attribute property should not be set");
    } catch (RuntimeException e) {
    // empty
    }
}
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)

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