use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testGetMultipleDocumentsQueryAndGZippedPOST.
@Test
public void testGetMultipleDocumentsQueryAndGZippedPOST() 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);
String data = "userdoc:kittens:5:6\nuserdoc:kittens:7:8\nuserdoc:kittens:9:10";
// Create with automatic GZIP encoding
MockHttpRequest request = new MockHttpRequest(data.getBytes("utf-8"), "/get/?id[0]=userdoc:kittens:1:2&id[1]=userdoc:kittens:3:4", true);
Query query = new Query(request.toRequest());
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(query);
assertEquals(5, factory.messages.size());
assertEquals(5, result.hits().size());
assertNull(result.hits().getErrorHit());
assertHits(result.hits(), "userdoc:kittens:1:2", "userdoc:kittens:3:4", "userdoc:kittens:5:6", "userdoc:kittens:7:8", "userdoc:kittens:9:10");
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testDocumentFieldNotSet.
@Test
public void testDocumentFieldNotSet() throws Exception {
Document doc1 = new Document(docType, new DocumentId("userdoc:kittens:5:1"));
doc1.setFieldValue("name", "asdf");
doc1.setFieldValue("description", "fdsafsdf");
doc1.setFieldValue("fluffiness", 10);
GetDocumentReply[] replies = new GetDocumentReply[] { new GetDocumentReply(doc1) };
Chain<Searcher> searchChain = createSearcherChain(replies);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=userdoc:kittens:5:1&field=image"));
assertNotNull(result.hits().getErrorHit());
assertEquals(1, result.hits().size());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"searcher\" code=\"16\" message=\"Resource not found.: " + "Field 'image' found in document type, but had no content in userdoc:kittens:5:1\"/>\n" + "</errors>\n" + "</result>\n", result);
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testQueryPassThrough.
/* Test that a query without any ids is passed through to the next chain */
@Test
public void testQueryPassThrough() throws Exception {
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
HitGroup hits = new HitGroup("mock");
hits.add(new Hit("blernsball"));
Chain<Searcher> searchChain = new Chain<>(searcher, new MockBackend(hits));
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?flarn=blern"));
assertEquals(0, factory.messages.size());
assertEquals(1, result.hits().size());
assertNotNull(result.hits().get("blernsball"));
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testResultWithMultipleErrors.
@Test
public void testResultWithMultipleErrors() throws Exception {
Document doc1 = new Document(docType, new DocumentId("userdoc:kittens:77:88"));
Document doc2 = new Document(docType, new DocumentId("userdoc:kittens:99:111"));
GetDocumentReply errorReply1 = new GetDocumentReply(doc1);
errorReply1.addError(new com.yahoo.messagebus.Error(123, "userdoc:kittens:77:88 had fleas."));
GetDocumentReply errorReply2 = new GetDocumentReply(doc2);
errorReply2.addError(new com.yahoo.messagebus.Error(456, "userdoc:kittens:99:111 shredded the curtains."));
GetDocumentReply[] replies = new GetDocumentReply[] { errorReply1, errorReply2 };
Chain<Searcher> searchChain = createSearcherChain(replies);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id[0]=userdoc:kittens:77:88&id[1]=userdoc:kittens:99:111"));
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"messagebus\" code=\"123\" message=\"userdoc:kittens:77:88 had fleas.\"/>\n" + "<error type=\"messagebus\" code=\"456\" message=\"userdoc:kittens:99:111 shredded the curtains.\"/>\n" + "</errors>\n" + "</result>\n", result);
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testResultWithNullDocument.
@Test
public void testResultWithNullDocument() 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[0]=userdoc:kittens:55:bad_document_id"));
// Document not found does not produce any hit at all, error or otherwise
assertNull(result.hits().getErrorHit());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "</result>\n", result);
}
Aggregations