use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class VespaSerializerTestCase method testExoticItemTypes.
@Test
public final void testExoticItemTypes() {
Item item = MarkerWordItem.createEndOfHost();
String q = VespaSerializer.serialize(item);
assertEquals("default contains ([{\"implicitTransforms\": false}]\"$\")", q);
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class VespaSerializerTestCase method testEmptyIndex.
@Test
public final void testEmptyIndex() {
Item item = new WordItem("nalle", true);
String q = VespaSerializer.serialize(item);
assertEquals("default contains \"nalle\"", q);
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class YqlParserTestCase method getRootWord.
private WordItem getRootWord(String yqlQuery) {
Item root = parse(yqlQuery).getRoot();
assertTrue(root instanceof WordItem);
return (WordItem) root;
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class YqlParserTestCase method testRaw.
@Test
public void testRaw() {
Item root = parse("select foo from bar where baz contains (\"yoni jo dima\");").getRoot();
assertTrue(root instanceof WordItem);
assertFalse(root instanceof ExactStringItem);
assertEquals("yoni jo dima", ((WordItem) root).getWord());
root = parse("select foo from bar where baz contains ([{\"grammar\":\"raw\"}]\"yoni jo dima\");").getRoot();
assertTrue(root instanceof WordItem);
assertFalse(root instanceof ExactStringItem);
assertEquals("yoni jo dima", ((WordItem) root).getWord());
root = parse("select foo from bar where userInput(\"yoni jo dima\");").getRoot();
assertTrue(root instanceof AndItem);
AndItem andItem = (AndItem) root;
assertEquals(3, andItem.getItemCount());
root = parse("select foo from bar where [{\"grammar\":\"raw\"}]userInput(\"yoni jo dima\");").getRoot();
assertTrue(root instanceof WordItem);
assertTrue(root instanceof ExactStringItem);
assertEquals("yoni jo dima", ((WordItem) root).getWord());
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class YqlParserTestCase method testWordAlternativesInPhrase.
@Test
public void testWordAlternativesInPhrase() {
QueryTree x = parse("select * from sources * where" + " foo contains phrase(\"forest\", alternatives({\"trees\": 1.0, \"tree\": 0.7}));");
Item root = x.getRoot();
assertSame(PhraseItem.class, root.getClass());
PhraseItem phrase = (PhraseItem) root;
assertEquals(2, phrase.getItemCount());
assertEquals("forest", ((WordItem) phrase.getItem(0)).getWord());
checkWordAlternativesContent((WordAlternativesItem) phrase.getItem(1));
}
Aggregations