Search in sources :

Example 11 with DocumentSourceSearcher

use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.

the class FieldCollapsingSearcherTestCase method testNoCollapsingIfNotAskedTo.

@Test
public void testNoCollapsingIfNotAskedTo() {
    // Set up
    Map<Searcher, Searcher> chained = new HashMap<>();
    FieldCollapsingSearcher collapse = new FieldCollapsingSearcher();
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    chained.put(collapse, docsource);
    Query q = new Query("?query=test_collapse");
    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 that no collapsing occured
    q = new Query("?query=test_collapse");
    r = doSearch(collapse, q, 0, 10, chained);
    assertEquals(8, r.getHitCount());
    assertEquals(1, docsource.getQueryCount());
}
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 12 with DocumentSourceSearcher

use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.

the class FieldCollapsingSearcherTestCase method testCollapsingDispersedCollection.

/**
 * Tests collapsing of "messy" data
 */
@Test
public void testCollapsingDispersedCollection() {
    // Set up
    Map<Searcher, Searcher> chained = new HashMap<>();
    FieldCollapsingSearcher collapse = new FieldCollapsingSearcher(1, 2.0, "amid");
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    chained.put(collapse, docsource);
    Query q = new Query("?query=test_collapse&collapse=true&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, 1));
    r.hits().add(createHit("http://acme.org/b.html", 10, 1));
    r.hits().add(createHit("http://acme.org/c.html", 10, 0));
    r.hits().add(createHit("http://acme.org/d.html", 10, 0));
    r.hits().add(createHit("http://acme.org/e.html", 10, 0));
    r.hits().add(createHit("http://acme.org/f.html", 10, 0));
    r.hits().add(createHit("http://acme.org/g.html", 10, 0));
    r.hits().add(createHit("http://acme.org/h.html", 10, 0));
    r.hits().add(createHit("http://acme.org/i.html", 10, 0));
    r.hits().add(createHit("http://acme.org/j.html", 10, 1));
    r.setTotalHitCount(10);
    docsource.addResult(q, r);
    // Test collapsing
    q = new Query("?query=test_collapse&collapse=true&collapsefield=amid");
    r = doSearch(collapse, q, 0, 3, chained);
    assertEquals(2, r.getHitCount());
    assertHit("http://acme.org/a.html", 10, 1, r.hits().get(0));
    assertHit("http://acme.org/c.html", 10, 0, 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 13 with DocumentSourceSearcher

use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.

the class FieldCollapsingSearcherTestCase method testCollapsingLargeCollection.

/**
 * Tests that collapsing many hits from one site works, and without
 * an excessive number of backend requests
 */
@Test
public void testCollapsingLargeCollection() {
    // Set up
    Map<Searcher, Searcher> chained = new HashMap<>();
    FieldCollapsingSearcher collapse = new FieldCollapsingSearcher(4, 2.0, "amid");
    DocumentSourceSearcher docsource = new DocumentSourceSearcher();
    chained.put(collapse, docsource);
    Query q = new Query("?query=test_collapse&collapsesize=1&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, 0));
    r.hits().add(createHit("http://acme.org/i.html", 5, 1));
    r.hits().add(createHit("http://acme.org/j.html", 4, 2));
    r.setTotalHitCount(10);
    docsource.addResult(q, r);
    // Test collapsing
    q = new Query("?query=test_collapse&collapsesize=1&collapsefield=amid");
    r = doSearch(collapse, q, 0, 2, chained);
    assertEquals(2, r.getHitCount());
    assertEquals(2, docsource.getQueryCount());
    assertHit("http://acme.org/a.html", 10, 0, r.hits().get(0));
    assertHit("http://acme.org/i.html", 5, 1, r.hits().get(1));
    // Next results
    docsource.resetQueryCount();
    r = doSearch(collapse, q, 2, 2, chained);
    assertEquals(1, r.getHitCount());
    assertEquals(2, docsource.getQueryCount());
    assertHit("http://acme.org/j.html", 4, 2, r.hits().get(0));
}
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 14 with DocumentSourceSearcher

use of com.yahoo.search.searchchain.testutil.DocumentSourceSearcher in project vespa by vespa-engine.

the class MultipleResultsTestCase method setUp.

@Before
public void setUp() {
    docSource = new DocumentSourceSearcher();
    searcher = new MultipleResultsSearcher();
    chain = new Chain<>("multipleresultschain", searcher, docSource);
}
Also used : MultipleResultsSearcher(com.yahoo.prelude.searcher.MultipleResultsSearcher) DocumentSourceSearcher(com.yahoo.search.searchchain.testutil.DocumentSourceSearcher) Before(org.junit.Before)

Aggregations

DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)14 Query (com.yahoo.search.Query)13 Result (com.yahoo.search.Result)11 Searcher (com.yahoo.search.Searcher)10 FieldCollapsingSearcher (com.yahoo.prelude.searcher.FieldCollapsingSearcher)8 HashMap (java.util.HashMap)8 Test (org.junit.Test)8 Chain (com.yahoo.component.chain.Chain)3 Hit (com.yahoo.search.result.Hit)3 Execution (com.yahoo.search.searchchain.Execution)3 Before (org.junit.Before)3 ComponentId (com.yahoo.component.ComponentId)1 QrSearchersConfig (com.yahoo.container.QrSearchersConfig)1 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1 JuniperSearcher (com.yahoo.prelude.searcher.JuniperSearcher)1 MultipleResultsSearcher (com.yahoo.prelude.searcher.MultipleResultsSearcher)1 QueryValidatingSearcher (com.yahoo.prelude.searcher.QueryValidatingSearcher)1 GroupList (com.yahoo.search.grouping.result.GroupList)1 HitGroup (com.yahoo.search.result.HitGroup)1