aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java10
-rw-r--r--container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java11
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java33
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java10
4 files changed, 31 insertions, 33 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
index 415ebd7871c..2f9e81c1607 100644
--- a/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
+++ b/container-search/src/main/java/com/yahoo/prelude/searcher/DocumentSourceSearcher.java
@@ -27,9 +27,12 @@ import java.util.Set;
* will be returned when attribute prefetch filling is requested.</p>
*
* @author bratseth
+ * @deprecated use {@link com.yahoo.search.searchchain.testutil.DocumentSourceSearcher}
*/
@SuppressWarnings({"rawtypes"})
+@Deprecated // TODO: Remove on Vespa 7
public class DocumentSourceSearcher extends Searcher {
+
// as for the SuppressWarnings annotation above, we are inside
// com.yahoo.prelude, this is old stuff, really no point firing off those
// warnings here...
@@ -38,7 +41,6 @@ public class DocumentSourceSearcher extends Searcher {
private Map<Query, Result> completelyFilledResults = new HashMap<>();
private Map<Query, Result> attributeFilledResults = new HashMap<>();
private Map<Query, Result> unFilledResults = new HashMap<>();
- //private Result defaultUnfilledResult;
/** Time (in ms) at which the index of this searcher was last modified */
long editionTimeStamp=0;
@@ -101,11 +103,11 @@ public class DocumentSourceSearcher extends Searcher {
}
/**
- * Returns a query clone which has offset and hits set to null. This is used by access to
+ * Returns a query clone which has source, offset and hits set to null. This is used by access to
* the maps using the query as key to achieve lookup independent of offset/hits value
*/
- private com.yahoo.search.Query getQueryKeyClone(com.yahoo.search.Query query) {
- com.yahoo.search.Query key=query.clone();
+ private Query getQueryKeyClone(Query query) {
+ Query key = query.clone();
key.setWindow(0,0);
key.getModel().setSources("");
return key;
diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java b/container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java
index 56a6a702962..f4973ba4239 100644
--- a/container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java
+++ b/container-search/src/main/java/com/yahoo/search/searchchain/testutil/DocumentSourceSearcher.java
@@ -28,7 +28,7 @@ import com.yahoo.search.searchchain.Execution;
* Any field in the configured hits which has a name starting by attribute
* will be returned when attribute prefetch filling is requested.</p>
*
- * @author bratseth
+ * @author bratseth
*/
public class DocumentSourceSearcher extends Searcher {
@@ -85,7 +85,6 @@ public class DocumentSourceSearcher extends Searcher {
private void addDefaultResults() {
Query q = new Query("?query=default");
Result r = new Result(q);
- // These four used to assign collapseId 1,2,3,4 - re-add that if needed
r.hits().add(new Hit("http://default-1.html", 0));
r.hits().add(new Hit("http://default-2.html", 0));
r.hits().add(new Hit("http://default-3.html", 0));
@@ -97,8 +96,7 @@ public class DocumentSourceSearcher extends Searcher {
@Override
public Result search(Query query, Execution execution) {
queryCount++;
- Result r;
- r = unFilledResults.get(getQueryKeyClone(query));
+ Result r = unFilledResults.get(getQueryKeyClone(query));
if (r == null) {
r = defaultFilledResult.clone();
} else {
@@ -111,12 +109,13 @@ public class DocumentSourceSearcher extends Searcher {
}
/**
- * Returns a query clone which has offset and hits set to null. This is used by access to
+ * Returns a query clone which has sourcr, offset and hits set to null. This is used by access to
* the maps using the query as key to achieve lookup independent of offset/hits value
*/
private Query getQueryKeyClone(Query query) {
- Query key=query.clone();
+ Query key = query.clone();
key.setWindow(0,0);
+ key.getModel().setSources("");
return key;
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java
index 4987f9902ce..086174a2b55 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java
@@ -17,16 +17,15 @@ import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.prelude.searcher.BlendingSearcher;
-import com.yahoo.prelude.searcher.DocumentSourceSearcher;
import com.yahoo.prelude.searcher.FillSearcher;
import com.yahoo.search.Searcher;
import com.yahoo.search.federation.FederationSearcher;
-import com.yahoo.search.federation.selection.TargetSelector;
import com.yahoo.search.result.ErrorMessage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
import com.yahoo.search.searchchain.SearchChain;
import com.yahoo.search.searchchain.SearchChainRegistry;
+import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -124,7 +123,6 @@ public class BlendingSearcherTestCase {
@Test
public void testitTwoPhase() {
-
DocumentSourceSearcher chain1 = new DocumentSourceSearcher();
DocumentSourceSearcher chain2 = new DocumentSourceSearcher();
DocumentSourceSearcher chain3 = new DocumentSourceSearcher();
@@ -139,19 +137,19 @@ public class BlendingSearcherTestCase {
r1.hits().add(new Hit("http://host1.com", 101){{setSource("one");}});
r1.hits().add(new Hit("http://host2.com", 102){{setSource("one");}});
r1.hits().add(new Hit("http://host3.com", 103){{setSource("one");}});
- chain1.addResultSet(q, r1);
+ chain1.addResult(q, r1);
r2.setTotalHitCount(17);
r2.hits().add(new Hit("http://host1.com", 101){{setSource("two");}});
r2.hits().add(new Hit("http://host2.com", 102){{setSource("two");}});
r2.hits().add(new Hit("http://host4.com", 104){{setSource("two");}});
- chain2.addResultSet(q, r2);
+ chain2.addResult(q, r2);
r3.setTotalHitCount(37);
r3.hits().add(new Hit("http://host5.com", 100){{setSource("three");}});
r3.hits().add(new Hit("http://host6.com", 106){{setSource("three");}});
r3.hits().add(new Hit("http://host7.com", 105){{setSource("three");}});
- chain3.addResultSet(q, r3);
+ chain3.addResult(q, r3);
BlendingSearcherWrapper blender1 = new BlendingSearcherWrapper();
blender1.addChained(chain1, "one");
@@ -215,10 +213,10 @@ public class BlendingSearcherTestCase {
r1.setTotalHitCount(1);
r1.hits().add(new FastHit("http://host1.com/", 101));
- chain1.addResultSet(q, r1);
+ chain1.addResult(q, r1);
r2.hits().add(new FastHit("http://host1.com/", 102));
r2.setTotalHitCount(1);
- chain2.addResultSet(q, r2);
+ chain2.addResult(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper("uri");
blender.addChained(new FillSearcher(chain1), "a");
@@ -239,10 +237,10 @@ public class BlendingSearcherTestCase {
Result r2 = new Result(q, ErrorMessage.createRequestTooLarge(null));
r1.setTotalHitCount(0);
- chain1.addResultSet(q, r1);
+ chain1.addResult(q, r1);
r2.hits().add(new FastHit("http://host1.com/", 102));
r2.setTotalHitCount(1);
- chain2.addResultSet(q, r2);
+ chain2.addResult(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(new FillSearcher(chain1), "a");
@@ -288,7 +286,7 @@ public class BlendingSearcherTestCase {
r1.hits().add(r1h1);
r1.hits().add(r1h2);
r1.hits().add(r1h3);
- chain1.addResultSet(q, r1);
+ chain1.addResult(q, r1);
r2.setTotalHitCount(3);
Hit r2h1 = new Hit("http://host1.com/relevancy201", 201);
@@ -303,7 +301,7 @@ public class BlendingSearcherTestCase {
r2.hits().add(r2h1);
r2.hits().add(r2h2);
r2.hits().add(r2h3);
- chain2.addResultSet(q, r2);
+ chain2.addResult(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(new FillSearcher(chain1), "chainedone");
@@ -343,7 +341,7 @@ public class BlendingSearcherTestCase {
r1.hits().add(r1h1);
r1.hits().add(r1h2);
r1.hits().add(r1h3);
- chain1.addResultSet(q, r1);
+ chain1.addResult(q, r1);
r2.setTotalHitCount(3);
Hit r2h1 = new Hit("http://host1.com/relevancy201", 201);
@@ -355,7 +353,7 @@ public class BlendingSearcherTestCase {
r2.hits().add(r2h1);
r2.hits().add(r2h2);
r2.hits().add(r2h3);
- chain2.addResultSet(q, r2);
+ chain2.addResult(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(chain1, "chainedone");
@@ -381,7 +379,7 @@ public class BlendingSearcherTestCase {
r1.setTotalHitCount(1);
Hit r1h1 = new Hit("http://first/relevancy100", 200);
r1.hits().add(r1h1);
- first.addResultSet(query, r1);
+ first.addResult(query, r1);
Result r2 = new Result(query);
r2.setTotalHitCount(2);
@@ -389,7 +387,7 @@ public class BlendingSearcherTestCase {
Hit r2h2 = new Hit("http://second/relevancy100", 100);
r2.hits().add(r2h1);
r2.hits().add(r2h2);
- second.addResultSet(query, r2);
+ second.addResult(query, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(new FillSearcher(first), "first");
@@ -479,13 +477,12 @@ public class BlendingSearcherTestCase {
Query query = new Query("/search?query=banana&search=first,nonesuch,second");
Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
- assertEquals(3, result.getConcreteHitCount());
+ assertEquals(4, result.getHitCount());
assertEquals(300.0, result.hits().get(1).getRelevance().getScore(), delta);
assertEquals(200.0, result.hits().get(2).getRelevance().getScore(), delta);
assertEquals(100.0, result.hits().get(3).getRelevance().getScore(), delta);
assertNotNull(result.hits().getError());
ErrorMessage e = result.hits().getError();
- //TODO: Do not depend on sources order
assertEquals("Could not resolve source ref 'nonesuch'. Valid source refs are first, second.",
e.getDetailedMessage());
}
diff --git a/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java
index ee735104caa..691f877dfba 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java
@@ -15,9 +15,9 @@ import com.yahoo.search.Result;
import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.prelude.hitfield.HitField;
import com.yahoo.search.Searcher;
-import com.yahoo.prelude.searcher.DocumentSourceSearcher;
import com.yahoo.prelude.searcher.QuotingSearcher;
import com.yahoo.search.searchchain.Execution;
+import com.yahoo.search.searchchain.testutil.DocumentSourceSearcher;
import org.junit.Test;
import java.util.ArrayList;
@@ -55,7 +55,7 @@ public class QuotingSearcherTestCase {
hit.setRelevance(new Relevance(1));
hit.setField("title", "smith & jones");
r.hits().add(hit);
- docsource.addResultSet(q, r);
+ docsource.addResult(q, r);
Result check = doSearch(s, q, 0, 10, chained);
assertEquals("smith &amp; jones", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
@@ -75,7 +75,7 @@ public class QuotingSearcherTestCase {
hit.setRelevance(new Relevance(1));
hit.setField("title", "&smith &jo& nes");
r.hits().add(hit);
- docsource.addResultSet(q, r);
+ docsource.addResult(q, r);
Result check = doSearch(s, q, 0, 10, chained);
assertEquals("&amp;smith &amp;jo&amp; nes", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
@@ -95,7 +95,7 @@ public class QuotingSearcherTestCase {
hit.setRelevance(new Relevance(1));
hit.setField("title", new HitField("title", "&smith &jo& nes"));
r.hits().add(hit);
- docsource.addResultSet(q, r);
+ docsource.addResult(q, r);
Result check = doSearch(s, q, 0, 10, chained);
assertEquals("&amp;smith &amp;jo&amp; nes", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
@@ -116,7 +116,7 @@ public class QuotingSearcherTestCase {
hit.setRelevance(new Relevance(1));
hit.setField("title", Integer.valueOf(42));
r.hits().add(hit);
- docsource.addResultSet(q, r);
+ docsource.addResult(q, r);
Result check = doSearch(s, q, 0, 10, chained);
// should not quote non-string properties
assertEquals(Integer.valueOf(42), check.hits().get(0).getField("title"));