Search in sources :

Example 56 with Hit

use of com.yahoo.search.result.Hit in project vespa by vespa-engine.

the class DeepHitIteratorTestCase method testRemove.

public void testRemove() {
    HitGroup hits = new HitGroup();
    hits.add(new Hit("foo"));
    hits.add(new Hit("bar"));
    Iterator<Hit> it = hits.deepIterator();
    try {
        it.remove();
        fail();
    } catch (IllegalStateException e) {
    // need to call next() first
    }
    assertTrue(it.hasNext());
    assertEquals("foo", it.next().getId().toString());
    assertTrue(it.hasNext());
    try {
        it.remove();
        fail();
    } catch (IllegalStateException e) {
    // prefetch done
    }
    assertEquals("bar", it.next().getId().toString());
    // no prefetch done
    it.remove();
    assertFalse(it.hasNext());
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup)

Example 57 with Hit

use of com.yahoo.search.result.Hit in project vespa by vespa-engine.

the class DeepHitIteratorTestCase method testEmpty.

public void testEmpty() {
    HitGroup hits = new HitGroup();
    Iterator<Hit> it = hits.deepIterator();
    assertFalse(it.hasNext());
    try {
        it.next();
        fail();
    } catch (NoSuchElementException e) {
    // regular iterator behavior
    }
}
Also used : Hit(com.yahoo.search.result.Hit) NoSuchElementException(java.util.NoSuchElementException) HitGroup(com.yahoo.search.result.HitGroup)

Example 58 with Hit

use of com.yahoo.search.result.Hit in project vespa by vespa-engine.

the class DeepHitIteratorTestCase method testFirstHitIsGroup.

public void testFirstHitIsGroup() {
    HitGroup root = new HitGroup();
    HitGroup group = new HitGroup();
    group.add(new Hit("foo"));
    root.add(group);
    root.add(new Hit("bar"));
    Iterator<Hit> it = root.deepIterator();
    assertTrue(it.hasNext());
    assertEquals("foo", it.next().getId().toString());
    assertTrue(it.hasNext());
    assertEquals("bar", it.next().getId().toString());
    assertFalse(it.hasNext());
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup)

Example 59 with Hit

use of com.yahoo.search.result.Hit in project vespa by vespa-engine.

the class YqlFieldAndSourceTestCase method setUp.

@Before
public void setUp() throws Exception {
    Query query = new Query("?query=test");
    Result result = new Result(query);
    Hit hit = createHit("lastHit", .1d, FIELD1, FIELD2, FIELD3);
    result.hits().add(hit);
    DocumentSourceSearcher mockBackend = new DocumentSourceSearcher();
    mockBackend.addResult(query, result);
    mockBackend.addSummaryClassByCopy(DEFAULT_SUMMARY_CLASS, Arrays.asList(FIELD1, FIELD2));
    mockBackend.addSummaryClassByCopy(Execution.ATTRIBUTEPREFETCH, Arrays.asList(FIELD2));
    mockBackend.addSummaryClassByCopy(THIRD_OPTION, Arrays.asList(FIELD3));
    DocumentdbInfoConfig config = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(buildDocumentdbArray()));
    searchChain = new Chain<>(new FieldFiller(config), mockBackend);
    context = Execution.Context.createContextStub(null);
    execution = new Execution(searchChain, context);
}
Also used : Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) Result(com.yahoo.search.Result) Before(org.junit.Before)

Example 60 with Hit

use of com.yahoo.search.result.Hit in project vespa by vespa-engine.

the class PeakQpsTestCase method checkSearch.

@Test
public void checkSearch() {
    MeasureQpsConfig config = new MeasureQpsConfig(new MeasureQpsConfig.Builder().outputmethod(MeasureQpsConfig.Outputmethod.METAHIT).queryproperty("qpsprobe"));
    Searcher s = new PeakQpsSearcher(config, Statistics.nullImplementation);
    Chain<Searcher> c = new Chain<>(s);
    Execution e = new Execution(c, Execution.Context.createContextStub());
    e.search(new Query("/?query=a"));
    new Execution(c, Execution.Context.createContextStub());
    Result r = e.search(new Query("/?query=a&qpsprobe=true"));
    final Hit hit = r.hits().get(0);
    assertTrue(hit instanceof PeakQpsSearcher.QpsHit);
    assertNotNull(hit.fields().get(PeakQpsSearcher.QpsHit.MEAN_QPS));
    assertNotNull(hit.fields().get(PeakQpsSearcher.QpsHit.PEAK_QPS));
}
Also used : Chain(com.yahoo.component.chain.Chain) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

Hit (com.yahoo.search.result.Hit)127 Result (com.yahoo.search.Result)72 Query (com.yahoo.search.Query)52 FastHit (com.yahoo.prelude.fastsearch.FastHit)42 Test (org.junit.Test)41 Execution (com.yahoo.search.searchchain.Execution)25 HitGroup (com.yahoo.search.result.HitGroup)21 Searcher (com.yahoo.search.Searcher)17 JSONString (com.yahoo.prelude.hitfield.JSONString)13 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)12 ErrorHit (com.yahoo.search.result.ErrorHit)10 Relevance (com.yahoo.search.result.Relevance)10 HashMap (java.util.HashMap)9 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)8 Group (com.yahoo.search.grouping.result.Group)8 ComponentId (com.yahoo.component.ComponentId)7 Chain (com.yahoo.component.chain.Chain)7 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)6 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)6 GroupList (com.yahoo.search.grouping.result.GroupList)5