Search in sources :

Example 66 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class ExecutionTestCase method testLinearExecutions.

public void testLinearExecutions() {
    // Make a chain
    List<Searcher> searchers1 = new ArrayList<>();
    searchers1.add(new TestSearcher("searcher1"));
    searchers1.add(new TestSearcher("searcher2"));
    searchers1.add(new TestSearcher("searcher3"));
    searchers1.add(new TestSearcher("searcher4"));
    Chain<Searcher> chain1 = new Chain<>(new ComponentId("chain1"), searchers1);
    // Make another chain containing two of the same searcher instances and two new
    List<Searcher> searchers2 = new ArrayList<>(searchers1);
    searchers2.set(1, new TestSearcher("searcher5"));
    searchers2.set(3, new TestSearcher("searcher6"));
    Chain<Searcher> chain2 = new Chain<>(new ComponentId("chain2"), searchers2);
    // Execute both
    Query query = new Query("test");
    Result result1 = new Execution(chain1, Execution.Context.createContextStub()).search(query);
    Result result2 = new Execution(chain2, Execution.Context.createContextStub()).search(query);
    // Verify results
    assertEquals(4, result1.getConcreteHitCount());
    assertNotNull(result1.hits().get("searcher1-1"));
    assertNotNull(result1.hits().get("searcher2-1"));
    assertNotNull(result1.hits().get("searcher3-1"));
    assertNotNull(result1.hits().get("searcher4-1"));
    assertEquals(4, result2.getConcreteHitCount());
    assertNotNull(result2.hits().get("searcher1-2"));
    assertNotNull(result2.hits().get("searcher5-1"));
    assertNotNull(result2.hits().get("searcher3-2"));
    assertNotNull(result2.hits().get("searcher6-1"));
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) ArrayList(java.util.ArrayList) ComponentId(com.yahoo.component.ComponentId) Result(com.yahoo.search.Result)

Example 67 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class QueryProfileTypeTestCase method setUp.

@Override
protected void setUp() {
    registry = new QueryProfileRegistry();
    type = new QueryProfileType(new ComponentId("testtype"));
    type.inherited().add(registry.getTypeRegistry().getComponent(new ComponentId("native")));
    typeStrict = new QueryProfileType(new ComponentId("testtypeStrict"));
    typeStrict.setStrict(true);
    user = new QueryProfileType(new ComponentId("user"));
    userStrict = new QueryProfileType(new ComponentId("userStrict"));
    userStrict.setStrict(true);
    registry.getTypeRegistry().register(type);
    registry.getTypeRegistry().register(typeStrict);
    registry.getTypeRegistry().register(user);
    registry.getTypeRegistry().register(userStrict);
    addTypeFields(type, registry.getTypeRegistry());
    type.addField(new FieldDescription("myUserQueryProfile", FieldType.fromString("query-profile:user", registry.getTypeRegistry())));
    addTypeFields(typeStrict, registry.getTypeRegistry());
    typeStrict.addField(new FieldDescription("myUserQueryProfile", FieldType.fromString("query-profile:userStrict", registry.getTypeRegistry())));
    addUserFields(user, registry.getTypeRegistry());
    addUserFields(userStrict, registry.getTypeRegistry());
}
Also used : QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType) ComponentId(com.yahoo.component.ComponentId) FieldDescription(com.yahoo.search.query.profile.types.FieldDescription)

Example 68 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class ProcessingFactory method createConcreteDocument.

private Document createConcreteDocument(Document document, ContainerDocumentConfig.Doctype typeConfig) {
    // Class name of the factory
    String componentId = typeConfig.factorycomponent();
    AbstractConcreteDocumentFactory cdf = docFactoryRegistry.getComponent(new ComponentId(componentId));
    if (cdf == null) {
        log.fine("Unable to get document factory component '" + componentId + "' from document factory registry.");
        return document;
    }
    return cdf.getDocumentCopy(document.getDataType().getName(), document, document.getId());
}
Also used : AbstractConcreteDocumentFactory(com.yahoo.docproc.AbstractConcreteDocumentFactory) ComponentId(com.yahoo.component.ComponentId)

Aggregations

ComponentId (com.yahoo.component.ComponentId)68 Test (org.junit.Test)25 Result (com.yahoo.search.Result)14 Query (com.yahoo.search.Query)13 Execution (com.yahoo.search.searchchain.Execution)13 ArrayList (java.util.ArrayList)10 Chain (com.yahoo.component.chain.Chain)8 Searcher (com.yahoo.search.Searcher)8 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)7 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)7 FederationSearcher (com.yahoo.search.federation.FederationSearcher)6 Hit (com.yahoo.search.result.Hit)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 ChainsConfig (com.yahoo.container.core.ChainsConfig)4 FilterChainRepository (com.yahoo.container.http.filter.FilterChainRepository)4 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)4 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)4 Component (com.yahoo.vespa.model.container.component.Component)4 HashMap (java.util.HashMap)4