use of com.yahoo.prelude.query.IndexedItem in project vespa by vespa-engine.
the class QueryTestCase method testPositiveTerms.
@Test
public void testPositiveTerms() {
Query q = new Query(httpEncode("/?query=-a \"b c\" d e"));
Item i = q.getModel().getQueryTree().getRoot();
List<IndexedItem> l = QueryTree.getPositiveTerms(i);
assertEquals(3, l.size());
}
use of com.yahoo.prelude.query.IndexedItem in project vespa by vespa-engine.
the class YqlParserTestCase method testMoreInheritedAnnotations.
@Test
public void testMoreInheritedAnnotations() {
final String yqlQuery = "select * from sources * where " + "([{\"ranked\": false}](foo contains \"a\" " + "and ([{\"ranked\": true}](bar contains \"b\" " + "or ([{\"ranked\": false}](foo contains \"c\" " + "and foo contains ([{\"ranked\": true}]\"d\")))))));";
QueryTree x = parse(yqlQuery);
List<IndexedItem> terms = QueryTree.getPositiveTerms(x);
assertEquals(4, terms.size());
for (IndexedItem term : terms) {
switch(term.getIndexedString()) {
case "a":
case "c":
assertFalse(((Item) term).isRanked());
break;
case "b":
case "d":
assertTrue(((Item) term).isRanked());
break;
default:
fail();
}
}
}
use of com.yahoo.prelude.query.IndexedItem 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());
}
}
Aggregations