use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class RewriterFeaturesTestCase method testConvertStringToQTree.
@Test
public final void testConvertStringToQTree() {
Execution placeholder = new Execution(Context.createContextStub());
SpecialTokenRegistry tokenRegistry = new SpecialTokenRegistry(new SpecialtokensConfig(new SpecialtokensConfig.Builder().tokenlist(new Tokenlist.Builder().name("default").tokens(new Tokens.Builder().token(ASCII_ELLIPSIS)))));
placeholder.context().setTokenRegistry(tokenRegistry);
Query query = new Query();
query.getModel().setExecution(placeholder);
Item parsed = RewriterFeatures.convertStringToQTree(query, "a b c " + ASCII_ELLIPSIS);
assertSame(AndItem.class, parsed.getClass());
assertEquals(4, ((CompositeItem) parsed).getItemCount());
assertEquals(ASCII_ELLIPSIS, ((CompositeItem) parsed).getItem(3).toString());
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class NGramSearcherTestCase method assertGramsWithSegmentationMixedAndPhrases.
public void assertGramsWithSegmentationMixedAndPhrases(Chain<Searcher> chain) {
// "first" "second" and "third" are segments in the "test" language
Item item = parseQuery("a gram14:\"afirstsecondthird b hi\"", Query.Type.ALL);
Query q = new Query("?query=ignored");
q.getModel().setLanguage(Language.UNKNOWN);
q.getModel().getQueryTree().setRoot(item);
new Execution(chain, createContextStub(indexFacts)).search(q);
assertEquals("AND a gram14:\"afirstsecondth firstsecondthi irstsecondthir rstsecondthird b hi\"", q.getModel().getQueryTree().toString());
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class NGramSearcherTestCase method assertGramsWithSegmentationSingleSegment.
public void assertGramsWithSegmentationSingleSegment(Chain<Searcher> chain) {
// "first" "second" and "third" are segments in the "test" language
Item item = parseQuery("gram14:first", Query.Type.ANY);
Query q = new Query("?query=ignored");
q.getModel().setLanguage(Language.UNKNOWN);
q.getModel().getQueryTree().setRoot(item);
new Execution(chain, createContextStub(indexFacts)).search(q);
assertEquals("gram14:first", q.getModel().getQueryTree().toString());
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class NGramSearcherTestCase method assertGramsWithSegmentationMixed.
public void assertGramsWithSegmentationMixed(Chain<Searcher> chain) {
// "first" "second" and "third" are segments in the "test" language
Item item = parseQuery("a gram14:afirstsecondthird b gram14:hi", Query.Type.ALL);
Query q = new Query("?query=ignored");
q.getModel().setLanguage(Language.UNKNOWN);
q.getModel().getQueryTree().setRoot(item);
new Execution(chain, createContextStub(indexFacts)).search(q);
assertEquals("AND a (AND gram14:afirstsecondth gram14:firstsecondthi gram14:irstsecondthir gram14:rstsecondthird) b gram14:hi", q.getModel().getQueryTree().toString());
}
use of com.yahoo.prelude.query.Item in project vespa by vespa-engine.
the class SerializeItemTestCase method serialize_connectivity.
@Test
public void serialize_connectivity() throws ParseException {
OrItem orItem = new OrItem();
{
WordItem first = new WordItem("first");
WordItem second = new WordItem("second");
first.setConnectivity(second, 3.14);
orItem.addItem(first);
orItem.addItem(second);
}
OrItem deSerialized = serializeThenParse(orItem);
WordItem first = (WordItem) deSerialized.getItem(0);
Item second = deSerialized.getItem(1);
assertThat(first.getConnectedItem(), is(second));
assertThat(first.getConnectivity(), is(3.14));
}
Aggregations