// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.searchchain; import com.yahoo.component.ComponentId; import com.yahoo.component.chain.Chain; import com.yahoo.component.chain.Phase; import com.yahoo.search.Searcher; import java.util.Collection; import java.util.List; /** * A named collection of searchers. *

* The searchers may have dependencies which define an ordering * of the searchers of this chain. *

* Search chains may inherit the searchers of other chains and modify * the inherited set of searchers. *

* Search chains may be versioned. The version and name string combined * is an unique identifier of a search chain. *

* A search chain cannot be modified once constructed. * * @author bratseth */ public class SearchChain extends Chain { public SearchChain(ComponentId id) { this(id, null, null); } public SearchChain(ComponentId id, Searcher... searchers) { this(id, List.of(searchers)); } public SearchChain(ComponentId id, Collection searchers) { this(id, searchers, null); } /** * Creates a search chain. *

* This search chain makes a copy of the given lists before return and does not modify the argument lists. *

* The total set of searchers included in this chain will be *

* * @param id the id of this search chain * @param searchers the searchers of this chain, or null if none * @param phases the phases of this chain */ public SearchChain(ComponentId id, Collection searchers, Collection phases) { super(id, searchers, phases); } /** For internal use only! */ public SearchChain(Chain chain) { super(chain.getId(), chain.components()); } /** * Returns an unmodifiable list of the searchers this search chain executs, in resolved execution order. * This includes all inherited (and not excluded) searchers. */ public List searchers() { return components(); } @Override public String toString() { StringBuilder b = new StringBuilder("search "); b.append(super.toString()); return b.toString(); } }