use of com.yahoo.prelude.query.Item 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.prelude.query.Item in project vespa by vespa-engine.
the class QueryTestCase method testQueryEquality.
/**
* Tests that query hash and equality is value dependent only
*/
@Test
public void testQueryEquality() {
String query = "RANK (+(AND \"baz gaz faz\" bazar) -\"foo bar foobar\") foofoo xyzzy";
String filter = "foofoo -\"foo bar foobar\" xyzzy +\"baz gaz faz\" +bazar";
Item root1 = parseQuery(query, filter, Query.Type.ANY);
Item root2 = parseQuery(query, filter, Query.Type.ANY);
assertEquals(root1.hashCode(), root2.hashCode());
assertEquals(root1, root2);
}
use of com.yahoo.prelude.query.Item 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.prelude.query.Item in project vespa by vespa-engine.
the class ParseTestCase method testRangeParsing.
@Test
public void testRangeParsing() {
Item root = tester.parseQuery("normal:[5;400]", null, Language.UNKNOWN, Query.Type.ANY, TestLinguistics.INSTANCE);
assertEquals(root.toString(), "normal:[5;400]");
assertEquals(root.getCode(), 5);
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class ParseTestCase method testSubstringExtraSpace2.
@Test
public void testSubstringExtraSpace2() {
Item root = tester.assertParsed("*substring", "* substring *", Query.Type.ANY);
assertTrue(root instanceof SuffixItem);
}
Aggregations