use of com.yahoo.search.Query in project vespa by vespa-engine.
the class SemanticSearcherTestCase method testWeightedSetItem.
// This test is order dependent. Fix it!!
public void testWeightedSetItem() {
Query q = new Query();
WeightedSetItem weightedSet = new WeightedSetItem("fieldName");
weightedSet.addToken("a", 1);
weightedSet.addToken("b", 2);
q.getModel().getQueryTree().setRoot(weightedSet);
assertSemantics("WEIGHTEDSET fieldName{[1]:\"a\",[2]:\"b\"}", q);
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class GroupedResultTestCase method testGroupedResult.
public void testGroupedResult() {
Result result = new Result(new Query("?query=foo"));
HitGroup hitGroup1 = new HitGroup("group1", 300);
hitGroup1.add(new Hit("group1.1", 200));
HitGroup hitGroup2 = new HitGroup("group2", 600);
Hit topLevelHit1 = new Hit("toplevel.1", 500);
Hit topLevelHit2 = new Hit("toplevel.2", 700);
result.hits().add(hitGroup1);
result.hits().add(topLevelHit1);
result.hits().add(hitGroup2);
result.hits().add(topLevelHit2);
hitGroup1.add(new Hit("group1.2", 800));
hitGroup2.add(new Hit("group2.1", 800));
hitGroup2.add(new Hit("group2.2", 300));
hitGroup2.add(new Hit("group2.3", 500));
// Should have 7 concrete hits, ordered as
// toplevel.2
// group2
// group2.1
// group2.3
// group2.2
// toplevel.1
// group1
// group1.2
// group1.1
// Assert this:
assertEquals(7, result.getConcreteHitCount());
assertEquals(4, result.getHitCount());
Hit topLevel2 = result.hits().get(0);
assertEquals("toplevel.2", topLevel2.getId().stringValue());
HitGroup returnedGroup2 = (HitGroup) result.hits().get(1);
assertEquals(3, returnedGroup2.getConcreteSize());
assertEquals(3, returnedGroup2.size());
assertEquals("group2.1", returnedGroup2.get(0).getId().stringValue());
assertEquals("group2.3", returnedGroup2.get(1).getId().stringValue());
assertEquals("group2.2", returnedGroup2.get(2).getId().stringValue());
Hit topLevel1 = result.hits().get(2);
assertEquals("toplevel.1", topLevel1.getId().stringValue());
HitGroup returnedGroup1 = (HitGroup) result.hits().get(3);
assertEquals(2, returnedGroup1.getConcreteSize());
assertEquals(2, returnedGroup1.size());
assertEquals("group1.2", returnedGroup1.get(0).getId().stringValue());
assertEquals("group1.1", returnedGroup1.get(1).getId().stringValue());
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class TilingTestCase method testTiling2.
/**
* This result contains center section and meta blocks.
* <p>
* Incidentally, this also tests using an old searcher in new search chains.
*/
public void testTiling2() throws IOException {
Chain<Searcher> chain = new Chain<>("tiling", new TiledResultProducer2());
// Query it
Query query = new Query("/tiled?query=foo");
Result result = callSearchAndSetRenderer(chain, query);
assertRendered(IOUtils.readFile(new File("src/test/java/com/yahoo/prelude/templates/test/tilingexample2.xml")), result);
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class GetRawWordTestCase method testGetRawWord.
@Test
public void testGetRawWord() {
Query query = new Query("?query=%C4%B0%C5%9EBANKASI%20GAZ%C4%B0EM%C4%B0R&searchChain=vespa");
assertEquals("AND \u0130\u015EBANKASI GAZ\u0130EM\u0130R", query.getModel().getQueryTree().toString());
AndItem root = (AndItem) query.getModel().getQueryTree().getRoot();
{
WordItem word = (WordItem) root.getItem(0);
assertEquals("\u0130\u015EBANKASI", word.getRawWord());
assertEquals(0, word.getOrigin().start);
assertEquals(9, word.getOrigin().end);
}
{
WordItem word = (WordItem) root.getItem(1);
assertEquals("GAZ\u0130EM\u0130R", word.getRawWord());
assertEquals(10, word.getOrigin().start);
assertEquals(18, word.getOrigin().end);
}
assertEquals("Total string is just these words", 18, ((WordItem) root.getItem(0)).getOrigin().getSuperstring().length());
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class HitConverterTestCase method requireThatHitHasContext.
@Test
public void requireThatHitHasContext() {
HitConverter converter = new HitConverter(new MySearcher(), new Query());
try {
converter.toSearchHit("69", new FS4Hit(1, createGlobalId(2), 3));
fail();
} catch (NullPointerException e) {
}
}
Aggregations