Search in sources :

Example 1 with SearchChain

use of com.yahoo.vespa.model.container.search.searchchain.SearchChain in project vespa by vespa-engine.

the class ContainerDocumentApi method setupLegacySearchers.

private void setupLegacySearchers(ContainerCluster cluster) {
    Set<ComponentSpecification> inherited = new TreeSet<>();
    SearchChain vespaGetChain = new SearchChain(new ChainSpecification(new ComponentId("vespaget"), new ChainSpecification.Inheritance(inherited, null), new ArrayList<>(), new TreeSet<>()));
    vespaGetChain.addInnerComponent(newVespaClientSearcher("com.yahoo.storage.searcher.GetSearcher"));
    SearchChain vespaVisitChain = new SearchChain(new ChainSpecification(new ComponentId("vespavisit"), new ChainSpecification.Inheritance(inherited, null), new ArrayList<>(), new TreeSet<>()));
    vespaVisitChain.addInnerComponent(newVespaClientSearcher("com.yahoo.storage.searcher.VisitSearcher"));
    SearchChains chains;
    if (cluster.getSearch() != null) {
        chains = cluster.getSearchChains();
    } else {
        chains = new SearchChains(cluster, "searchchain");
    }
    chains.add(vespaGetChain);
    chains.add(vespaVisitChain);
    if (cluster.getSearch() == null) {
        ContainerSearch containerSearch = new ContainerSearch(cluster, chains, new ContainerSearch.Options());
        cluster.setSearch(containerSearch);
        ProcessingHandler<SearchChains> searchHandler = new ProcessingHandler<>(chains, "com.yahoo.search.handler.SearchHandler");
        searchHandler.addServerBindings("http://*/search/*", "https://*/search/*");
        cluster.addComponent(searchHandler);
    }
}
Also used : SearchChains(com.yahoo.vespa.model.container.search.searchchain.SearchChains) ComponentSpecification(com.yahoo.component.ComponentSpecification) ProcessingHandler(com.yahoo.vespa.model.container.component.chain.ProcessingHandler) ContainerSearch(com.yahoo.vespa.model.container.search.ContainerSearch) ChainSpecification(com.yahoo.component.chain.model.ChainSpecification) ArrayList(java.util.ArrayList) SearchChain(com.yahoo.vespa.model.container.search.searchchain.SearchChain) TreeSet(java.util.TreeSet) ComponentId(com.yahoo.component.ComponentId)

Example 2 with SearchChain

use of com.yahoo.vespa.model.container.search.searchchain.SearchChain in project vespa by vespa-engine.

the class ContainerIncludeTest method include.

@Test
public void include() {
    VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/container/data/containerinclude/");
    VespaModel model = creator.create();
    assertThat(model.getContainerClusters().size(), is(1));
    ContainerCluster cluster = model.getContainerClusters().values().iterator().next();
    assertThat(cluster.getSearchChains(), notNullValue());
    Map<String, SearchChain> searchChainMap = new HashMap<>();
    for (SearchChain searchChain : cluster.getSearchChains().allChains().allComponents()) {
        searchChainMap.put(searchChain.getId().stringValue(), searchChain);
    }
    assertThat(searchChainMap.get("searchchain1"), notNullValue());
    assertThat(searchChainMap.get("searchchain1").getInnerComponents().size(), is(1));
    assertThat(searchChainMap.get("searchchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher1"));
    assertThat(searchChainMap.get("searchchain2"), notNullValue());
    assertThat(searchChainMap.get("searchchain2").getInnerComponents().size(), is(1));
    assertThat(searchChainMap.get("searchchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher2"));
    assertThat(searchChainMap.get("searchchain3"), notNullValue());
    assertThat(searchChainMap.get("searchchain3").getInnerComponents().size(), is(1));
    assertThat(searchChainMap.get("searchchain3").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher3"));
    assertThat(searchChainMap.get("searchchain4"), notNullValue());
    assertThat(searchChainMap.get("searchchain4").getInnerComponents().size(), is(1));
    assertThat(searchChainMap.get("searchchain4").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher4"));
    assertThat(cluster.getDocprocChains(), notNullValue());
    Map<String, DocprocChain> docprocChainMap = new HashMap<>();
    for (DocprocChain docprocChain : cluster.getDocprocChains().allChains().allComponents()) {
        docprocChainMap.put(docprocChain.getId().stringValue(), docprocChain);
    }
    assertThat(docprocChainMap.get("docprocchain1"), notNullValue());
    assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().size(), is(1));
    assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor1"));
    assertThat(docprocChainMap.get("docprocchain2"), notNullValue());
    assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().size(), is(1));
    assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor2"));
    assertThat(cluster.getProcessingChains(), notNullValue());
    Map<String, ProcessingChain> processingChainMap = new HashMap<>();
    for (ProcessingChain processingChain : cluster.getProcessingChains().allChains().allComponents()) {
        processingChainMap.put(processingChain.getId().stringValue(), processingChain);
    }
    assertThat(processingChainMap.get("processingchain1"), notNullValue());
    assertThat(processingChainMap.get("processingchain1").getInnerComponents().size(), is(1));
    assertThat(processingChainMap.get("processingchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor1"));
    assertThat(processingChainMap.get("processingchain2"), notNullValue());
    assertThat(processingChainMap.get("processingchain2").getInnerComponents().size(), is(1));
    assertThat(processingChainMap.get("processingchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor2"));
}
Also used : VespaModelCreatorWithFilePkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg) ProcessingChain(com.yahoo.vespa.model.container.processing.ProcessingChain) HashMap(java.util.HashMap) VespaModel(com.yahoo.vespa.model.VespaModel) DocprocChain(com.yahoo.vespa.model.container.docproc.DocprocChain) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SearchChain(com.yahoo.vespa.model.container.search.searchchain.SearchChain) Test(org.junit.Test)

Aggregations

SearchChain (com.yahoo.vespa.model.container.search.searchchain.SearchChain)2 ComponentId (com.yahoo.component.ComponentId)1 ComponentSpecification (com.yahoo.component.ComponentSpecification)1 ChainSpecification (com.yahoo.component.chain.model.ChainSpecification)1 VespaModel (com.yahoo.vespa.model.VespaModel)1 ProcessingHandler (com.yahoo.vespa.model.container.component.chain.ProcessingHandler)1 DocprocChain (com.yahoo.vespa.model.container.docproc.DocprocChain)1 ProcessingChain (com.yahoo.vespa.model.container.processing.ProcessingChain)1 ContainerSearch (com.yahoo.vespa.model.container.search.ContainerSearch)1 SearchChains (com.yahoo.vespa.model.container.search.searchchain.SearchChains)1 VespaModelCreatorWithFilePkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1