use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class PartialFillTestCase method testPartitioning.
@Test
public void testPartitioning() {
FS4 fs4 = new FS4();
Query a = new Query("/?query=foo");
Query b = new Query("/?query=bar");
// equal to a
Query c = new Query("/?query=foo");
Result r = new Result(new Query("/?query=ignorethis"));
for (int i = 0; i < 7; i++) {
FastHit h = new FastHit();
h.setQuery(a);
h.setFillable();
r.hits().add(h);
}
for (int i = 0; i < 5; i++) {
FastHit h = new FastHit();
h.setQuery(b);
h.setFillable();
r.hits().add(h);
}
for (int i = 0; i < 3; i++) {
FastHit h = new FastHit();
h.setQuery(c);
h.setFillable();
r.hits().add(h);
}
for (int i = 0; i < 2; i++) {
FastHit h = new FastHit();
// no query assigned
h.setFillable();
r.hits().add(h);
}
for (int i = 0; i < 5; i++) {
FastHit h = new FastHit();
// not fillable
h.setQuery(a);
r.hits().add(h);
}
for (int i = 0; i < 5; i++) {
FastHit h = new FastHit();
// already filled
h.setQuery(a);
h.setFilled("default");
r.hits().add(h);
}
doFill(fs4, r, "default");
assertNull(r.hits().getErrorHit());
assertEquals(4, fs4.history.size());
assertEquals(a, fs4.history.get(0).getQuery());
assertEquals(7, fs4.history.get(0).getHitCount());
assertEquals(b, fs4.history.get(1).getQuery());
assertEquals(5, fs4.history.get(1).getHitCount());
assertEquals(c, fs4.history.get(2).getQuery());
assertEquals(3, fs4.history.get(2).getHitCount());
assertEquals(r.getQuery(), fs4.history.get(3).getQuery());
assertEquals(2, fs4.history.get(3).getHitCount());
}
use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class DocsumDefinitionTestCase method testDecoding.
@Test
public void testDecoding() {
String summary_cf = "file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg";
DocsumDefinitionSet set = createDocsumDefinitionSet(summary_cf);
FastHit hit = new FastHit();
set.lazyDecode(null, makeDocsum(), hit);
assertEquals("Arts/Celebrities/Madonna", hit.getField("TOPIC"));
assertEquals("1", hit.getField("EXTINFOSOURCE").toString());
assertEquals("10", hit.getField("LANG1").toString());
assertEquals("352", hit.getField("WORDS").toString());
assertEquals("index:0/0/0/" + FastHit.asHexString(hit.getGlobalId()), hit.getId().toString());
}
use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class QuotingSearcherTestCase method testFieldQuotingWithNoisyStrings.
public void testFieldQuotingWithNoisyStrings() {
Map<Searcher, Searcher> chained = new HashMap<>();
Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/" + "searcher/test/testquoting.cfg");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(s, docsource);
Query q = new Query("?query=a");
Result r = new Result(q);
Hit hit = new FastHit();
hit.setId("http://abc.html");
hit.setRelevance(new Relevance(1));
hit.setField("title", new HitField("title", "&smith &jo& nes"));
r.hits().add(hit);
docsource.addResultSet(q, r);
Result check = doSearch(s, q, 0, 10, chained);
assertEquals("&smith &jo& nes", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
}
use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class QuotingSearcherTestCase method testNoQuotingWithOtherTypes.
public void testNoQuotingWithOtherTypes() {
Map<Searcher, Searcher> chained = new HashMap<>();
Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/" + "searcher/test/testquoting.cfg");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(s, docsource);
Query q = new Query("?query=a");
Result r = new Result(q);
Hit hit = new FastHit();
hit.setId("http://abc.html");
hit.setRelevance(new Relevance(1));
hit.setField("title", new Integer(42));
r.hits().add(hit);
docsource.addResultSet(q, r);
Result check = doSearch(s, q, 0, 10, chained);
// should not quote non-string properties
assertEquals(new Integer(42), check.hits().get(0).getField("title"));
}
use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class QuotingSearcherTestCase method testBasicQuoting.
public void testBasicQuoting() {
Map<Searcher, Searcher> chained = new HashMap<>();
Searcher s = createQuotingSearcher("file:src/test/java/com/yahoo/prelude/" + "searcher/test/testquoting.cfg");
DocumentSourceSearcher docsource = new DocumentSourceSearcher();
chained.put(s, docsource);
Query q = new Query("?query=a");
Result r = new Result(q);
Hit hit = new FastHit();
hit.setId("http://abc.html");
hit.setRelevance(new Relevance(1));
hit.setField("title", "smith & jones");
r.hits().add(hit);
docsource.addResultSet(q, r);
Result check = doSearch(s, q, 0, 10, chained);
assertEquals("smith & jones", check.hits().get(0).getField("title").toString());
assertTrue(check.hits().get(0).fields().containsKey("title"));
}
Aggregations