Search in sources :

Example 11 with QueryProfileType

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

the class QueryFromProfileTestCase method testQueryFromProfile2.

public void testQueryFromProfile2() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfileType rootType = new QueryProfileType("root");
    rootType.inherited().add(registry.getTypeRegistry().getComponent("native"));
    registry.getTypeRegistry().register(rootType);
    QueryProfile root = new QueryProfile("root");
    root.setType(rootType);
    registry.register(root);
    QueryProfile queryBest = new QueryProfile("querybest");
    queryBest.setType(registry.getTypeRegistry().getComponent("model"));
    queryBest.set("queryString", "best", registry);
    registry.register(queryBest);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    Query query = new Query(HttpRequest.createTestRequest("?query=overrides&model=querybest", Method.GET), cRegistry.getComponent("root"));
    assertEquals("overrides", query.properties().get("model.queryString"));
    assertEquals("overrides", query.getModel().getQueryTree().toString());
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 12 with QueryProfileType

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

the class FieldTypeTestCase method testConvertToFromString.

public void testConvertToFromString() {
    QueryProfileTypeRegistry registry = new QueryProfileTypeRegistry();
    registry.register(new QueryProfileType("foo"));
    assertEquals("string", FieldType.fromString("string", registry).stringValue());
    assertEquals("boolean", FieldType.fromString("boolean", registry).stringValue());
    assertEquals("query-profile", FieldType.fromString("query-profile", registry).stringValue());
    assertEquals("query-profile:foo", FieldType.fromString("query-profile:foo", registry).stringValue());
}
Also used : QueryProfileTypeRegistry(com.yahoo.search.query.profile.types.QueryProfileTypeRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 13 with QueryProfileType

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

the class NativePropertiesTestCase method testNativeInStrict.

public void testNativeInStrict() {
    QueryProfileType strictType = new QueryProfileType("strict");
    strictType.setStrict(true);
    QueryProfile strict = new QueryProfile("profile");
    strict.setType(strictType);
    try {
        new Query(HttpRequest.createTestRequest("?hits=10&tracelevel=5", Method.GET), strict.compile(null));
        fail("Above statement should throw");
    } catch (QueryException e) {
    // As expected.
    }
    try {
        new Query(HttpRequest.createTestRequest("?notnative=5", Method.GET), strict.compile(null));
        fail("Above statement should throw");
    } catch (QueryException e) {
        // As expected.
        assertThat(Exceptions.toMessageString(e), containsString("Could not set 'notnative' to '5':" + " 'notnative' is not declared in query profile type 'strict', and the type is strict"));
    }
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryException(com.yahoo.prelude.query.QueryException) Query(com.yahoo.search.Query) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 14 with QueryProfileType

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

the class PatchMatchingTestCase method testPatchMatchingVersions.

/**
 * Check that the path matching works with versioned profiles
 */
public void testPatchMatchingVersions() {
    QueryProfileType type = new QueryProfileType("type");
    type.setMatchAsPath(true);
    QueryProfile a = new QueryProfile("a");
    a.setType(type);
    QueryProfile abee11 = new QueryProfile("a/bee:1.1");
    abee11.setType(type);
    abee11.addInherited(a);
    QueryProfile abee13 = new QueryProfile("a/bee:1.3");
    abee13.setType(type);
    abee13.addInherited(a);
    QueryProfile abeece = new QueryProfile("a/bee/ce");
    abeece.setType(type);
    abeece.addInherited(abee13);
    QueryProfileRegistry registry = new QueryProfileRegistry();
    registry.register(a);
    registry.register(abee11);
    registry.register(abee13);
    registry.register(abeece);
    registry.freeze();
    // No "default" registered
    assertNull(registry.findQueryProfile(null));
    assertEquals("a", registry.findQueryProfile("a").getId().getName());
    assertEquals("a/bee:1.1", registry.findQueryProfile("a/bee:1.1").getId().toString());
    assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee").getId().toString());
    assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee:1").getId().toString());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee").getId().getName());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
    assertEquals("a/bee:1.1", registry.findQueryProfile("a/bee/cede:1.1").getId().toString());
    assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee/cede").getId().toString());
    assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee/cede:1").getId().toString());
    assertEquals("a", registry.findQueryProfile("a/foo/bee/cede").getId().getName());
    assertNull(registry.findQueryProfile("abee"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 15 with QueryProfileType

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

the class PatchMatchingTestCase method testQuirkyNames.

public void testQuirkyNames() {
    QueryProfileType type = new QueryProfileType("type");
    type.setMatchAsPath(true);
    QueryProfile a = new QueryProfile("/a");
    a.setType(type);
    QueryProfile abee = new QueryProfile("/a//bee");
    abee.setType(type);
    abee.addInherited(a);
    QueryProfile abeece = new QueryProfile("/a//bee/ce/");
    abeece.setType(type);
    abeece.addInherited(abee);
    QueryProfileRegistry registry = new QueryProfileRegistry();
    registry.register(a);
    registry.register(abee);
    registry.register(abeece);
    registry.freeze();
    // No "default" registered
    assertNull(registry.findQueryProfile(null));
    assertEquals("/a", registry.findQueryProfile("/a").getId().getName());
    assertNull(registry.findQueryProfile("a"));
    assertEquals("/a//bee", registry.findQueryProfile("/a//bee").getId().getName());
    assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/").getId().getName());
    assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce").getId().getName());
    assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/dee").getId().getName());
    assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/dee/eee/").getId().getName());
    assertEquals("/a//bee", registry.findQueryProfile("/a//bee/cede").getId().getName());
    assertEquals("/a", registry.findQueryProfile("/a/foo/bee/cede").getId().getName());
    assertEquals("/a", registry.findQueryProfile("/a/bee").getId().getName());
    assertNull(registry.findQueryProfile("abee"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Aggregations

QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)28 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)14 QueryProfile (com.yahoo.search.query.profile.QueryProfile)12 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)11 ComponentId (com.yahoo.component.ComponentId)7 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)7 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)5 CompoundName (com.yahoo.processing.request.CompoundName)4 Query (com.yahoo.search.Query)4 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)3 ArrayList (java.util.ArrayList)3 Element (org.w3c.dom.Element)3 NamedReader (com.yahoo.io.reader.NamedReader)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 ComponentSpecification (com.yahoo.component.ComponentSpecification)1 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 QueryException (com.yahoo.prelude.query.QueryException)1 DimensionalMap (com.yahoo.search.query.profile.compiled.DimensionalMap)1 QueryProfileConfigurer (com.yahoo.search.query.profile.config.QueryProfileConfigurer)1