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'");
}
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);
}
Aggregations