Search in sources :

Example 76 with Query

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

the class CachingSearcherTestCase method testNoCacheWrite.

@Test
public final void testNoCacheWrite() {
    readyResult(QUERY_A_NOCACHEWRITE_TRUE);
    Execution e = new Execution(searchChain, Execution.Context.createContextStub());
    Result r = e.search(new Query(QUERY_A_NOCACHEWRITE_TRUE));
    assertEquals(10, r.hits().getConcreteSize());
    Query query = new Query(QUERY_A_NOCACHEWRITE_TRUE);
    Result expected = new Result(query);
    hits.addResultSet(query, expected);
    e = new Execution(searchChain, Execution.Context.createContextStub());
    r = e.search(new Query(QUERY_A_NOCACHEWRITE_TRUE));
    assertEquals(0, r.hits().getConcreteSize());
    assertEquals(2, hits.getQueryCount());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 77 with Query

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

the class FieldCollapsingSearcherTestCase method testFieldCollapsingTwoPhaseSelectSummary.

// This test depends on DocumentSourceSearcher filling the hits
// with whatever data it got, ignoring actual summary arguments
// in the fill call, then saying the hits are filled for the
// ignored argument. Rewrite to contain different summaries if
// DocumentSourceSearcher gets extended.
@Test
public void testFieldCollapsingTwoPhaseSelectSummary() {
    // Set up
    Map<Searcher, Searcher> chained = new HashMap<>();
    FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    chained.put(collapse, docsource);
    // Caveat: Collapse is set to false, because that's what the
    // collapser asks for
    Query q = new Query("?query=test_collapse&collapsefield=amid&summary=placeholder");
    // The searcher turns off collapsing further on in the chain
    q.properties().set("collapse", "0");
    Result r = new Result(q);
    r.hits().add(createHit("http://acme.org/a.html", 10, 0));
    r.hits().add(createHit("http://acme.org/b.html", 9, 0));
    r.hits().add(createHit("http://acme.org/c.html", 9, 1));
    r.hits().add(createHit("http://acme.org/d.html", 8, 1));
    r.hits().add(createHit("http://acme.org/e.html", 8, 2));
    r.hits().add(createHit("http://acme.org/f.html", 7, 2));
    r.hits().add(createHit("http://acme.org/g.html", 7, 3));
    r.hits().add(createHit("http://acme.org/h.html", 6, 3));
    r.setTotalHitCount(8);
    docsource.addResult(q, r);
    // Test basic collapsing on mid
    q = new Query("?query=test_collapse&collapsefield=amid&summary=placeholder");
    r = doSearch(collapse, q, 0, 10, chained);
    assertEquals(4, r.getHitCount());
    assertEquals(1, docsource.getQueryCount());
    assertTrue(r.isFilled("placeholder"));
    assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
    assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
    assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
    assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
    docsource.resetQueryCount();
    // Test basic collapsing on mid
    q = new Query("?collapse.summary=short&query=test_collapse&collapsefield=amid&summary=placeholder");
    r = doSearch(collapse, q, 0, 10, chained);
    assertEquals(4, r.getHitCount());
    assertEquals(1, docsource.getQueryCount());
    assertFalse(r.isFilled("placeholder"));
    assertTrue(r.isFilled("short"));
    assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
    assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
    assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
    assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
}
Also used : Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 78 with Query

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

the class FieldCollapsingSearcherTestCase method testFieldCollapsingTwoPhase.

@Test
public void testFieldCollapsingTwoPhase() {
    // Set up
    Map<Searcher, Searcher> chained = new HashMap<>();
    FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    chained.put(collapse, docsource);
    // Caveat: Collapse is set to false, because that's what the
    // collapser asks for
    Query q = new Query("?query=test_collapse&collapsefield=amid");
    // The searcher turns off collapsing further on in the chain
    q.properties().set("collapse", "0");
    Result r = new Result(q);
    r.hits().add(createHit("http://acme.org/a.html", 10, 0));
    r.hits().add(createHit("http://acme.org/b.html", 9, 0));
    r.hits().add(createHit("http://acme.org/c.html", 9, 1));
    r.hits().add(createHit("http://acme.org/d.html", 8, 1));
    r.hits().add(createHit("http://acme.org/e.html", 8, 2));
    r.hits().add(createHit("http://acme.org/f.html", 7, 2));
    r.hits().add(createHit("http://acme.org/g.html", 7, 3));
    r.hits().add(createHit("http://acme.org/h.html", 6, 3));
    r.setTotalHitCount(8);
    docsource.addResult(q, r);
    // Test basic collapsing on mid
    q = new Query("?query=test_collapse&collapsefield=amid");
    r = doSearch(collapse, q, 0, 10, chained);
    assertEquals(4, r.getHitCount());
    assertEquals(1, docsource.getQueryCount());
    assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
    assertHit("http://acme.org/c.html", 9, 1, r.hits().get(1));
    assertHit("http://acme.org/e.html", 8, 2, r.hits().get(2));
    assertHit("http://acme.org/g.html", 7, 3, r.hits().get(3));
}
Also used : Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 79 with Query

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

the class FieldCollapsingSearcherTestCase method testQueryTransformAndCollapsing.

@Test
public void testQueryTransformAndCollapsing() {
    // Set up
    Map<Searcher, Searcher> chained = new HashMap<>();
    FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    Searcher messUp = new QueryMessupSearcher();
    chained.put(collapse, messUp);
    chained.put(messUp, docsource);
    // Caveat: Collapse is set to false, because that's what the
    // collapser asks for
    Query q = new Query("?query=test_collapse+b&collapsefield=amid");
    // The searcher turns off collapsing further on in the chain
    q.properties().set("collapse", "0");
    Result r = new Result(q);
    r.hits().add(createHit("http://acme.org/a.html", 10, 0));
    r.hits().add(createHit("http://acme.org/b.html", 9, 0));
    r.hits().add(createHit("http://acme.org/c.html", 9, 0));
    r.hits().add(createHit("http://acme.org/d.html", 8, 0));
    r.hits().add(createHit("http://acme.org/e.html", 8, 0));
    r.hits().add(createHit("http://acme.org/f.html", 7, 0));
    r.hits().add(createHit("http://acme.org/g.html", 7, 0));
    r.hits().add(createHit("http://acme.org/h.html", 6, 1));
    r.setTotalHitCount(8);
    docsource.addResult(q, r);
    // Test basic collapsing on mid
    q = new Query("?query=test_collapse&collapsefield=amid");
    r = doSearch(collapse, q, 0, 2, chained);
    assertEquals(2, docsource.getQueryCount());
    assertEquals(2, r.getHitCount());
    assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
    assertHit("http://acme.org/h.html", 6, 1, r.hits().get(1));
}
Also used : Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 80 with Query

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

the class FieldCollapsingSearcherTestCase method testFieldCollapsingWithoutHitsHugeOffset.

@Test
public void testFieldCollapsingWithoutHitsHugeOffset() {
    Map<Searcher, Searcher> chained = new HashMap<>();
    FieldCollapsingSearcher collapse = new FieldCollapsingSearcher("other");
    ZeroHitsControl checker = new ZeroHitsControl();
    chained.put(collapse, checker);
    Query q = new Query("?query=test_collapse&collapsefield=amid");
    Result r = doSearch(collapse, q, 1000, 0, chained);
    assertEquals(0, r.getHitCount());
    assertNull(r.hits().getError());
    assertEquals(1, checker.queryCount);
}
Also used : Query(com.yahoo.search.Query) HashMap(java.util.HashMap) Searcher(com.yahoo.search.Searcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) FieldCollapsingSearcher(com.yahoo.prelude.searcher.FieldCollapsingSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

Query (com.yahoo.search.Query)689 Test (org.junit.Test)415 Result (com.yahoo.search.Result)229 Execution (com.yahoo.search.searchchain.Execution)184 Searcher (com.yahoo.search.Searcher)82 QueryProfile (com.yahoo.search.query.profile.QueryProfile)63 Hit (com.yahoo.search.result.Hit)52 Chain (com.yahoo.component.chain.Chain)47 IndexFacts (com.yahoo.prelude.IndexFacts)44 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)37 AndItem (com.yahoo.prelude.query.AndItem)33 WordItem (com.yahoo.prelude.query.WordItem)33 FastHit (com.yahoo.prelude.fastsearch.FastHit)31 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)27 HitGroup (com.yahoo.search.result.HitGroup)24 Item (com.yahoo.prelude.query.Item)21 HashMap (java.util.HashMap)20 CacheKey (com.yahoo.prelude.fastsearch.CacheKey)18 GroupingRequest (com.yahoo.search.grouping.GroupingRequest)18 ArrayList (java.util.ArrayList)18