Search in sources :

Example 41 with QueryProfileRegistry

use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.

the class TypedProfilesConfigurationTestCase method testIt.

/**
 * Asserts that everything is read correctly from this configuration
 */
public void testIt() {
    QueryProfileConfigurer configurer = new QueryProfileConfigurer("file:src/test/java/com/yahoo/search/query/profile/config/test/typed-profiles.cfg");
    QueryProfileRegistry registry = configurer.getCurrentRegistry();
    QueryProfileTypeRegistry types = registry.getTypeRegistry();
    // Assert that each type was read correctly
    QueryProfileType testType = types.getComponent("testtype");
    assertEquals("testtype", testType.getId().getName());
    assertFalse(testType.isStrict());
    assertFalse(testType.getMatchAsPath());
    assertEquals(7, testType.fields().size());
    assertEquals("myString", testType.getField("myString").getName());
    assertTrue(testType.getField("myString").isMandatory());
    assertTrue(testType.getField("myString").isOverridable());
    assertFalse(testType.getField("myInteger").isMandatory());
    assertFalse(testType.getField("myInteger").isOverridable());
    FieldDescription field = testType.getField("myUserQueryProfile");
    assertEquals("reference to a query profile of type 'user'", field.getType().toInstanceDescription());
    assertTrue(field.getAliases().contains("myqp"));
    assertTrue(field.getAliases().contains("user-profile"));
    QueryProfileType testTypeStrict = types.getComponent("testtypestrict");
    assertTrue(testTypeStrict.isStrict());
    assertTrue(testTypeStrict.getMatchAsPath());
    assertEquals(7, testTypeStrict.fields().size());
    assertEquals("reference to a query profile of type 'userstrict'", testTypeStrict.getField("myUserQueryProfile").getType().toInstanceDescription());
    QueryProfileType user = types.getComponent("user");
    assertFalse(user.isStrict());
    assertFalse(user.getMatchAsPath());
    assertEquals(2, user.fields().size());
    assertEquals(String.class, user.getField("myUserString").getType().getValueClass());
    QueryProfileType userStrict = types.getComponent("userstrict");
    assertTrue(userStrict.isStrict());
    assertFalse(userStrict.getMatchAsPath());
    assertEquals(2, userStrict.fields().size());
}
Also used : QueryProfileConfigurer(com.yahoo.search.query.profile.config.QueryProfileConfigurer) QueryProfileTypeRegistry(com.yahoo.search.query.profile.types.QueryProfileTypeRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType) FieldDescription(com.yahoo.search.query.profile.types.FieldDescription)

Example 42 with QueryProfileRegistry

use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.

the class RankProfileTestCase method verifyRankProfile.

private void verifyRankProfile(RankProfile rankProfile, AttributeFields attributeFields) {
    assertEquals(0.78, rankProfile.getTermwiseLimit(), 0.000001);
    assertEquals(8, rankProfile.getNumThreadsPerSearch());
    assertEquals(70, rankProfile.getMinHitsPerThread());
    assertEquals(1200, rankProfile.getNumSearchPartitions());
    RawRankProfile rawRankProfile = new RawRankProfile(rankProfile, new QueryProfileRegistry(), attributeFields);
    assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.termwise_limit").isPresent());
    assertEquals("0.78", findProperty(rawRankProfile.configProperties(), "vespa.matching.termwise_limit").get());
    assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.numthreadspersearch").isPresent());
    assertEquals("8", findProperty(rawRankProfile.configProperties(), "vespa.matching.numthreadspersearch").get());
    assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.minhitsperthread").isPresent());
    assertEquals("70", findProperty(rawRankProfile.configProperties(), "vespa.matching.minhitsperthread").get());
    assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.numsearchpartitions").isPresent());
    assertEquals("1200", findProperty(rawRankProfile.configProperties(), "vespa.matching.numsearchpartitions").get());
}
Also used : RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry)

Example 43 with QueryProfileRegistry

use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.

the class RankProfileTestCase method assertQueryFeatureTypeSettings.

private static void assertQueryFeatureTypeSettings(RankProfile profile, Search search) {
    RawRankProfile rawProfile = new RawRankProfile(profile, new QueryProfileRegistry(), new AttributeFields(search));
    assertEquals("tensor(x[10])", findProperty(rawProfile.configProperties(), "vespa.type.query.tensor1").get());
    assertEquals("tensor(y{})", findProperty(rawProfile.configProperties(), "vespa.type.query.tensor2").get());
    assertFalse(findProperty(rawProfile.configProperties(), "vespa.type.query.tensor3").isPresent());
    assertFalse(findProperty(rawProfile.configProperties(), "vespa.type.query.numeric").isPresent());
}
Also used : RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) AttributeFields(com.yahoo.searchdefinition.derived.AttributeFields)

Example 44 with QueryProfileRegistry

use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.

the class RankProfileTestCase method assertAttributeTypeSettings.

private static void assertAttributeTypeSettings(RankProfile profile, Search search) {
    RawRankProfile rawProfile = new RawRankProfile(profile, new QueryProfileRegistry(), new AttributeFields(search));
    assertEquals("tensor(x[10])", findProperty(rawProfile.configProperties(), "vespa.type.attribute.a").get());
    assertEquals("tensor(y{})", findProperty(rawProfile.configProperties(), "vespa.type.attribute.b").get());
    assertEquals("tensor(x[])", findProperty(rawProfile.configProperties(), "vespa.type.attribute.c").get());
}
Also used : RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) AttributeFields(com.yahoo.searchdefinition.derived.AttributeFields)

Example 45 with QueryProfileRegistry

use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.

the class RankingExpressionInliningTestCase method testMacroInliningPreserveArithemticOrdering.

@Test
public void testMacroInliningPreserveArithemticOrdering() throws ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
    builder.importString("search test {\n" + "    document test { \n" + "        field a type double { \n" + "            indexing: attribute \n" + "        }\n" + "        field b type double { \n" + "            indexing: attribute \n" + "        }\n" + "    }\n" + "    \n" + "    rank-profile parent {\n" + "        constants {\n" + "            p1: 7 \n" + "            p2: 0 \n" + "        }\n" + "        first-phase {\n" + "            expression: p1 * add\n" + "        }\n" + "        macro inline add() {\n" + "            expression: 3 + attribute(a) + attribute(b) * mul3\n" + "        }\n" + "        macro inline mul3() {\n" + "            expression: attribute(a) * 3 + singleif\n" + "        }\n" + "        macro inline singleif() {\n" + "            expression: if (p1 < attribute(a), 1, 2) == 0\n" + "        }\n" + "    }\n" + "    rank-profile child inherits parent {\n" + "        macro inline add() {\n" + "            expression: 9 + attribute(a)\n" + "        }\n" + "    }\n" + "\n" + "}\n");
    builder.build();
    Search s = builder.getSearch();
    RankProfile parent = rankProfileRegistry.getRankProfile(s, "parent").compile(new QueryProfileRegistry());
    assertEquals("7.0 * (3 + attribute(a) + attribute(b) * (attribute(a) * 3 + if (7.0 < attribute(a), 1, 2) == 0))", parent.getFirstPhaseRanking().getRoot().toString());
    RankProfile child = rankProfileRegistry.getRankProfile(s, "child").compile(new QueryProfileRegistry());
    assertEquals("7.0 * (9 + attribute(a))", child.getFirstPhaseRanking().getRoot().toString());
}
Also used : QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) Test(org.junit.Test)

Aggregations

QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)68 Test (org.junit.Test)38 QueryProfile (com.yahoo.search.query.profile.QueryProfile)24 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)16 RawRankProfile (com.yahoo.searchdefinition.derived.RawRankProfile)16 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)14 Query (com.yahoo.search.Query)11 AttributeFields (com.yahoo.searchdefinition.derived.AttributeFields)11 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)11 Pair (com.yahoo.collections.Pair)8 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)8 Search (com.yahoo.searchdefinition.Search)8 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)7 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)6 SDField (com.yahoo.searchdefinition.document.SDField)5 ComponentId (com.yahoo.component.ComponentId)4 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)4 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)4