use of com.yahoo.search.query.rewrite.RewritesConfig in project vespa by vespa-engine.
the class SearchChainDispatcherSearcherTestCase method testChainContinuation.
/**
* Searchers down the chain after SearchChainDispatcher
* should be executed
*/
@SuppressWarnings("deprecation")
public void testChainContinuation() {
// 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 only misspell rewriter
Chain<Searcher> marketSearchChain = new Chain<>(US_MARKET_SEARCH_CHAIN, misspellRewriter);
// 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 the dispatcher and the name rewriter
ArrayList<Searcher> searchers = new ArrayList<>();
searchers.add(searchChainDispatcher);
searchers.add(nameRewriter);
// Create a chain containing only the dispatcher
Chain<Searcher> mainSearchChain = new Chain<>(searchers);
Execution execution = new Execution(mainSearchChain, Execution.Context.createContextStub(registry, null));
new QueryRewriteSearcherTestUtils(execution);
IntentModel intentModel = new IntentModel(utils.createInterpretation("wills smith", 0.9, true, false), utils.createInterpretation("will smith", 1.0, false, true));
utils.assertRewrittenQuery("?query=willl+smith&QRWChain=" + US_MARKET_SEARCH_CHAIN + "&" + MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" + MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" + NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true&" + NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true", "query 'OR (AND willl smith) (AND will smith) " + "\"will smith\" \"will smith movies\" " + "\"will smith news\" \"will smith imdb\" " + "\"will smith lyrics\" \"will smith dead\" " + "\"will smith nfl\" \"will smith new movie hancock\" " + "\"will smith biography\"'", intentModel);
}
use of com.yahoo.search.query.rewrite.RewritesConfig in project vespa by vespa-engine.
the class GenericExpansionRewriterTestCase method setUp.
/**
* Load the GenericExpansionRewriterSearcher and prepare the
* execution object
*/
protected void setUp() {
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
fileList.put(GenericExpansionRewriter.GENERIC_EXPAND_DICT, new File(GENERIC_EXPAND_DICT_PATH));
GenericExpansionRewriter searcher = new GenericExpansionRewriter(config, fileList);
Execution execution = QueryRewriteSearcherTestUtils.createExecutionObj(searcher);
utils = new QueryRewriteSearcherTestUtils(execution);
}
use of com.yahoo.search.query.rewrite.RewritesConfig in project vespa by vespa-engine.
the class NameRewriterTestCase method setUp.
/**
* Load the NameRewriterSearcher and prepare the
* execution object
*/
protected void setUp() {
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
fileList.put(NameRewriter.NAME_ENTITY_EXPAND_DICT, new File(NAME_ENTITY_EXPAND_DICT_PATH));
NameRewriter searcher = new NameRewriter(config, fileList);
Execution execution = QueryRewriteSearcherTestUtils.createExecutionObj(searcher);
utils = new QueryRewriteSearcherTestUtils(execution);
}
use of com.yahoo.search.query.rewrite.RewritesConfig in project vespa by vespa-engine.
the class QueryRewriteSearcherTestUtils method createConfigObj.
/**
* Create config object based on config path
*
* @param configPath path for the searcher config
*/
public static RewritesConfig createConfigObj(String configPath) {
ConfigGetter<RewritesConfig> getter = new ConfigGetter<>(RewritesConfig.class);
RewritesConfig config = getter.getConfig(configPath);
return config;
}
use of com.yahoo.search.query.rewrite.RewritesConfig in project vespa by vespa-engine.
the class QueryRewriteSearcherTestCase method setUp.
/**
* Load the QueryRewriteSearcher and prepare the
* execution object
*/
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 a chain of two rewriters
ArrayList<Searcher> searchers = new ArrayList<>();
searchers.add(misspellRewriter);
searchers.add(nameRewriter);
Execution execution = QueryRewriteSearcherTestUtils.createExecutionObj(searchers);
utils = new QueryRewriteSearcherTestUtils(execution);
}
Aggregations