use of com.yahoo.search.query.parser.ParserEnvironment in project vespa by vespa-engine.
the class ResegmentingTestCase method setUp.
@Before
public void setUp() throws Exception {
ParserEnvironment env = new ParserEnvironment();
parser = new YqlParser(env);
}
use of com.yahoo.search.query.parser.ParserEnvironment in project vespa by vespa-engine.
the class YqlParserTestCase method testFieldAliases.
@Test
public void testFieldAliases() {
IndexInfoConfig modelConfig = new IndexInfoConfig(new IndexInfoConfig.Builder().indexinfo(new Indexinfo.Builder().name("music").command(new Command.Builder().indexname("title").command("index")).alias(new Alias.Builder().alias("song").indexname("title"))));
IndexModel model = new IndexModel(modelConfig, (QrSearchersConfig) null);
IndexFacts indexFacts = new IndexFacts(model);
ParserEnvironment parserEnvironment = new ParserEnvironment().setIndexFacts(indexFacts);
YqlParser configuredParser = new YqlParser(parserEnvironment);
QueryTree x = configuredParser.parse(new Parsable().setQuery("select * from sources * where title contains \"a\" and song contains \"b\";"));
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(2, terms.size());
for (IndexedItem term : terms) {
assertEquals("title", term.getIndexName());
}
}
use of com.yahoo.search.query.parser.ParserEnvironment in project vespa by vespa-engine.
the class WashPhrasesTestCase method transformQuery.
private String transformQuery(String rawQuery) {
Parser parser = ParserFactory.newInstance(Query.Type.ALL, new ParserEnvironment());
Item root = parser.parse(new Parsable().setQuery(rawQuery)).getRoot();
if (root instanceof NullItem) {
return null;
}
return root.toString();
}
use of com.yahoo.search.query.parser.ParserEnvironment in project vespa by vespa-engine.
the class CJKSearcherTestCase method assertTransformed.
private void assertTransformed(String queryString, String expected, Query.Type mode, Language actualLanguage, Language queryLanguage, Linguistics linguistics) {
Parser parser = ParserFactory.newInstance(mode, new ParserEnvironment().setIndexFacts(indexFacts).setLinguistics(linguistics));
Item root = parser.parse(new Parsable().setQuery(queryString).setLanguage(actualLanguage)).getRoot();
assertFalse(root instanceof NullItem);
Query query = new Query("?language=" + queryLanguage.languageCode());
query.getModel().getQueryTree().setRoot(root);
new Execution(new Chain<Searcher>(new CJKSearcher()), new Execution.Context(null, indexFacts, null, null, linguistics)).search(query);
assertEquals(expected, query.getModel().getQueryTree().getRoot().toString());
}
use of com.yahoo.search.query.parser.ParserEnvironment in project vespa by vespa-engine.
the class ParsingTester method parseQuery.
public Item parseQuery(String query, String filter, Language language, Query.Type type, Linguistics linguistics) {
Parser parser = ParserFactory.newInstance(type, new ParserEnvironment().setIndexFacts(indexFacts).setLinguistics(linguistics).setSpecialTokens(tokenRegistry.getSpecialTokens("default")));
Item root = parser.parse(new Parsable().setQuery(query).setFilter(filter).setLanguage(language)).getRoot();
if (root instanceof NullItem) {
return null;
}
return root;
}
Aggregations