use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class QuerySnapshotSearcherTestCase method test.
public void test() {
Searcher searcher = new QuerySnapshotSearcher();
Result result = doSearch(searcher, new Query(), 0, 10);
Hit hit = result.hits().get(0);
assertEquals(String.valueOf(Double.POSITIVE_INFINITY), hit.getRelevance().toString());
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class QuotingSearcherTestCase method testBasicQuotingWithNoisyStrings.
public void testBasicQuotingWithNoisyStrings() {
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 &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.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testQueryOverridesDefaults.
@Test
public void testQueryOverridesDefaults() throws Exception {
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id[0]=userdoc:kittens:1:2&id[1]=userdoc:kittens:3:4&priority=LOW_2&route=highwaytohell&timeout=58"));
assertEquals(2, factory.messages.size());
long lastTimeout = 58000;
{
Message m = factory.messages.get(0);
assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
GetDocumentMessage gdm = (GetDocumentMessage) m;
DocumentId d = gdm.getDocumentId();
assertEquals("userdoc:kittens:1:2", d.toString());
assertEquals("[all]", gdm.getFieldSet());
assertEquals(DocumentProtocol.Priority.LOW_2, gdm.getPriority());
assertEquals(Route.parse("highwaytohell"), gdm.getRoute());
assertTrue(lastTimeout >= gdm.getTimeRemaining());
lastTimeout = gdm.getTimeRemaining();
}
{
Message m = factory.messages.get(1);
assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
GetDocumentMessage gdm = (GetDocumentMessage) m;
DocumentId d = gdm.getDocumentId();
assertEquals("userdoc:kittens:3:4", d.toString());
assertEquals("[all]", gdm.getFieldSet());
assertEquals(DocumentProtocol.Priority.LOW_2, gdm.getPriority());
assertEquals(Route.parse("highwaytohell"), gdm.getRoute());
assertTrue(lastTimeout >= gdm.getTimeRemaining());
}
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testGetSingleDocumentQuery.
@Test
public void testGetSingleDocumentQuery() throws Exception {
// Needs auto-reply
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=userdoc:kittens:1:2"));
System.out.println("HTTP request is " + result.getQuery().getHttpRequest());
assertEquals(1, factory.messages.size());
{
Message m = factory.messages.get(0);
assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
GetDocumentMessage gdm = (GetDocumentMessage) m;
DocumentId d = gdm.getDocumentId();
assertEquals("userdoc:kittens:1:2", d.toString());
assertEquals("[all]", gdm.getFieldSet());
}
assertEquals(1, result.hits().size());
assertHits(result.hits(), "userdoc:kittens:1:2");
// By default, document hit should not have its hit fields set
DocumentHit hit = (DocumentHit) result.hits().get(0);
assertEquals(0, hit.fieldKeys().size());
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testDocumentFieldWithDocumentNotFound.
@Test
public void testDocumentFieldWithDocumentNotFound() throws Exception {
DocumentSessionFactory factory = new DocumentSessionFactory(docType, null, true);
factory.setNullReply(true);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=userdoc:kittens:1:2&field=name"));
assertNotNull(result.hits().getErrorHit());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"searcher\" code=\"16\" message=\"Resource not found.: " + "Document not found, could not return field 'name'\"/>\n" + "</errors>\n" + "</result>\n", result);
}
Aggregations