Search in sources :

Example 6 with RewritesConfig

use of com.yahoo.search.query.rewrite.RewritesConfig in project vespa by vespa-engine.

the class QueryRewriteSearcherTestCase method testInvalidFSAConfigPath.

/**
 * Invalid FSA config path
 * Query will be passed to next rewriter
 */
public void testInvalidFSAConfigPath() {
    // Instantiate Name Rewriter with fake FSA path
    RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(FAKE_FSA_CONFIG_PATH);
    HashMap<String, File> fileList = new HashMap<>();
    fileList.put(NameRewriter.NAME_ENTITY_EXPAND_DICT, new File(FAKE_FSA_PATH));
    NameRewriter nameRewriterWithFakePath = new NameRewriter(config, fileList);
    // Instantiate Misspell Rewriter
    MisspellRewriter misspellRewriter = new MisspellRewriter();
    // Create a chain of two rewriters
    ArrayList<Searcher> searchers = new ArrayList<>();
    searchers.add(misspellRewriter);
    searchers.add(nameRewriterWithFakePath);
    Execution execution = QueryRewriteSearcherTestUtils.createExecutionObj(searchers);
    QueryRewriteSearcherTestUtils utilsWithFakePath = new QueryRewriteSearcherTestUtils(execution);
    utilsWithFakePath.assertRewrittenQuery("?query=will smith&" + NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true", "query 'AND will smith'");
}
Also used : RewritesConfig(com.yahoo.search.query.rewrite.RewritesConfig) File(java.io.File)

Example 7 with RewritesConfig

use of com.yahoo.search.query.rewrite.RewritesConfig in project vespa by vespa-engine.

the class SearchChainDispatcherSearcherTestCase method setUp.

/**
 * Load the QueryRewriteSearcher and prepare the
 * execution object
 */
@SuppressWarnings("deprecation")
protected void setUp() {
    // Instantiate Name Rewriter
    RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(NAME_REWRITER_CONFIG_PATH);
    HashMap<String, File> fileList = new HashMap<>();
    fileList.put(NameRewriter.NAME_ENTITY_EXPAND_DICT, new File(NAME_ENTITY_EXPAND_DICT_PATH));
    NameRewriter nameRewriter = new NameRewriter(config, fileList);
    // Instantiate Misspell Rewriter
    MisspellRewriter misspellRewriter = new MisspellRewriter();
    // Create market search chain of two rewriters
    ArrayList<Searcher> searchers = new ArrayList<>();
    searchers.add(misspellRewriter);
    searchers.add(nameRewriter);
    Chain<Searcher> marketSearchChain = new Chain<>(US_MARKET_SEARCH_CHAIN, searchers);
    // Add market search chain to the registry
    SearchChainRegistry registry = new SearchChainRegistry();
    registry.register(marketSearchChain);
    // Instantiate Search Chain Dispatcher Searcher
    SearchChainDispatcherSearcher searchChainDispatcher = new SearchChainDispatcherSearcher();
    // Create a chain containing only the dispatcher
    Chain<Searcher> mainSearchChain = new Chain<>(searchChainDispatcher);
    Execution execution = new Execution(mainSearchChain, Execution.Context.createContextStub(registry, null));
    utils = new QueryRewriteSearcherTestUtils(execution);
}
Also used : Chain(com.yahoo.component.chain.Chain) RewritesConfig(com.yahoo.search.query.rewrite.RewritesConfig) SearchChainRegistry(com.yahoo.search.searchchain.SearchChainRegistry) File(java.io.File)

Aggregations

RewritesConfig (com.yahoo.search.query.rewrite.RewritesConfig)7 File (java.io.File)6 Chain (com.yahoo.component.chain.Chain)2 SearchChainRegistry (com.yahoo.search.searchchain.SearchChainRegistry)2 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)1