summaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-05-27 13:05:31 +0200
committerGitHub <noreply@github.com>2018-05-27 13:05:31 +0200
commitc4f1deffdcab1a65d4aa64de840c909db929d4d4 (patch)
tree82018910c9c970d7cd3b3380621bedd2d8031b5c /container-search/src/test/java/com/yahoo/prelude
parenta940c9883183a8697fc5fa389355789d1d47f5b6 (diff)
Revert "Bratseth/iterate over indexes not fields 2"
Diffstat (limited to 'container-search/src/test/java/com/yahoo/prelude')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/BlendingSearcherTestCase.java35
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java4
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/searcher/test/QuotingSearcherTestCase.java10
3 files changed, 27 insertions, 22 deletions
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 7761bca2773..4987f9902ce 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,15 +17,16 @@ 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;
@@ -39,6 +40,8 @@ import static org.junit.Assert.assertTrue;
* @author Bob Travis
* @author bratseth
*/
+// The SuppressWarnings is to shut up the compiler about using
+// deprecated FastHit constructor in the tests.
@SuppressWarnings({ "rawtypes" })
public class BlendingSearcherTestCase {
@@ -121,6 +124,7 @@ public class BlendingSearcherTestCase {
@Test
public void testitTwoPhase() {
+
DocumentSourceSearcher chain1 = new DocumentSourceSearcher();
DocumentSourceSearcher chain2 = new DocumentSourceSearcher();
DocumentSourceSearcher chain3 = new DocumentSourceSearcher();
@@ -135,19 +139,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.addResult(q, r1);
+ chain1.addResultSet(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.addResult(q, r2);
+ chain2.addResultSet(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.addResult(q, r3);
+ chain3.addResultSet(q, r3);
BlendingSearcherWrapper blender1 = new BlendingSearcherWrapper();
blender1.addChained(chain1, "one");
@@ -211,10 +215,10 @@ public class BlendingSearcherTestCase {
r1.setTotalHitCount(1);
r1.hits().add(new FastHit("http://host1.com/", 101));
- chain1.addResult(q, r1);
+ chain1.addResultSet(q, r1);
r2.hits().add(new FastHit("http://host1.com/", 102));
r2.setTotalHitCount(1);
- chain2.addResult(q, r2);
+ chain2.addResultSet(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper("uri");
blender.addChained(new FillSearcher(chain1), "a");
@@ -235,10 +239,10 @@ public class BlendingSearcherTestCase {
Result r2 = new Result(q, ErrorMessage.createRequestTooLarge(null));
r1.setTotalHitCount(0);
- chain1.addResult(q, r1);
+ chain1.addResultSet(q, r1);
r2.hits().add(new FastHit("http://host1.com/", 102));
r2.setTotalHitCount(1);
- chain2.addResult(q, r2);
+ chain2.addResultSet(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(new FillSearcher(chain1), "a");
@@ -284,7 +288,7 @@ public class BlendingSearcherTestCase {
r1.hits().add(r1h1);
r1.hits().add(r1h2);
r1.hits().add(r1h3);
- chain1.addResult(q, r1);
+ chain1.addResultSet(q, r1);
r2.setTotalHitCount(3);
Hit r2h1 = new Hit("http://host1.com/relevancy201", 201);
@@ -299,7 +303,7 @@ public class BlendingSearcherTestCase {
r2.hits().add(r2h1);
r2.hits().add(r2h2);
r2.hits().add(r2h3);
- chain2.addResult(q, r2);
+ chain2.addResultSet(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(new FillSearcher(chain1), "chainedone");
@@ -339,7 +343,7 @@ public class BlendingSearcherTestCase {
r1.hits().add(r1h1);
r1.hits().add(r1h2);
r1.hits().add(r1h3);
- chain1.addResult(q, r1);
+ chain1.addResultSet(q, r1);
r2.setTotalHitCount(3);
Hit r2h1 = new Hit("http://host1.com/relevancy201", 201);
@@ -351,7 +355,7 @@ public class BlendingSearcherTestCase {
r2.hits().add(r2h1);
r2.hits().add(r2h2);
r2.hits().add(r2h3);
- chain2.addResult(q, r2);
+ chain2.addResultSet(q, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(chain1, "chainedone");
@@ -377,7 +381,7 @@ public class BlendingSearcherTestCase {
r1.setTotalHitCount(1);
Hit r1h1 = new Hit("http://first/relevancy100", 200);
r1.hits().add(r1h1);
- first.addResult(query, r1);
+ first.addResultSet(query, r1);
Result r2 = new Result(query);
r2.setTotalHitCount(2);
@@ -385,7 +389,7 @@ public class BlendingSearcherTestCase {
Hit r2h2 = new Hit("http://second/relevancy100", 100);
r2.hits().add(r2h1);
r2.hits().add(r2h2);
- second.addResult(query, r2);
+ second.addResultSet(query, r2);
BlendingSearcherWrapper blender = new BlendingSearcherWrapper();
blender.addChained(new FillSearcher(first), "first");
@@ -475,12 +479,13 @@ 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(4, result.getHitCount());
+ assertEquals(3, result.getConcreteHitCount());
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/JuniperSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
index 9f4a12d24e6..f71c0803ce8 100644
--- a/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/searcher/test/JuniperSearcherTestCase.java
@@ -28,9 +28,9 @@ import java.util.List;
import java.util.Map;
/**
- * Tests juniper highlighting
+ * Tests conversion of juniper highlighting to XML
*
- * @author Steinar Knutsen
+ * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
*/
public class JuniperSearcherTestCase {
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 691f877dfba..ee735104caa 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.addResult(q, r);
+ docsource.addResultSet(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.addResult(q, r);
+ docsource.addResultSet(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.addResult(q, r);
+ docsource.addResultSet(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.addResult(q, r);
+ docsource.addResultSet(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"));