use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testBadPriorityValue.
@Test
public void testBadPriorityValue() 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=userdoc:kittens:1:2&priority=onkel_jubalon"));
assertNotNull(result.hits().getErrorHit());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"searcher\" code=\"3\" message=\"Illegal query: " + "java.lang.IllegalArgumentException: No enum const" + (Util.isJava7Compatible() ? "ant " : " class ") + "com.yahoo.documentapi.messagebus.protocol.DocumentProtocol" + (Util.isJava7Compatible() ? "." : "$") + "Priority.onkel_jubalon\"/>\n" + "</errors>\n" + "</result>\n", result);
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testJsonRendererSetting.
@Test
public void testJsonRendererSetting() 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);
Query query = newQuery("?id=userdoc:kittens:1:2&format=json");
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(query);
assertFalse(result.getTemplating().getTemplates() instanceof DocumentXMLTemplate);
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testVespaXMLTemplate.
@Test
public void testVespaXMLTemplate() throws Exception {
Document doc1 = new Document(docType, new DocumentId("userdoc:kittens:3:4"));
doc1.setFieldValue("name", "mittens");
doc1.setFieldValue("description", "it's a cat");
doc1.setFieldValue("fluffiness", 8);
Document doc2 = new Document(docType, new DocumentId("userdoc:kittens:1:2"));
doc2.setFieldValue("name", "garfield");
doc2.setFieldValue("description", "preliminary research indicates <em>hatred</em> of mondays. caution advised");
doc2.setFieldValue("fluffiness", 2);
Document doc3 = new Document(docType, new DocumentId("userdoc:kittens:77:88"));
GetDocumentReply errorReply = new GetDocumentReply(doc3);
errorReply.addError(new com.yahoo.messagebus.Error(123, "userdoc:kittens:77:88 lost in a <ni!>\"shrubbery\"</ni!>"));
GetDocumentReply[] replies = new GetDocumentReply[] { new GetDocumentReply(doc1), new GetDocumentReply(doc2), errorReply };
// Use a predefined reply list to ensure messages are answered out of order
Chain<Searcher> searchChain = createSearcherChain(replies);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(// TODO!
newQuery("?id[0]=userdoc:kittens:77:88&id[1]=userdoc:kittens:1:2&id[2]=userdoc:kittens:3:4"));
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"messagebus\" code=\"123\" message=\"userdoc:kittens:77:88 lost in a <ni!>"shrubbery"</ni!>\"/>\n" + "</errors>\n" + "<document documenttype=\"kittens\" documentid=\"userdoc:kittens:1:2\">\n" + " <name>garfield</name>\n" + " <description>preliminary research indicates <em>hatred</em> of mondays. caution advised</description>\n" + " <fluffiness>2</fluffiness>\n" + "</document>\n" + "<document documenttype=\"kittens\" documentid=\"userdoc:kittens:3:4\">\n" + " <name>mittens</name>\n" + " <description>it's a cat</description>\n" + " <fluffiness>8</fluffiness>\n" + "</document>\n" + "</result>\n", result);
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class GetSearcherTestCase method testDocumentFieldEscapeXML.
@Test
public void testDocumentFieldEscapeXML() throws Exception {
Document doc1 = new Document(docType, new DocumentId("userdoc:kittens:5:1"));
doc1.setFieldValue("name", "asfd");
doc1.setFieldValue("description", "<script type=\"evil/madness\">horror & screams</script>");
doc1.setFieldValue("fluffiness", 0);
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=description"));
assertNull(result.hits().getErrorHit());
assertEquals("text/xml", result.getTemplating().getTemplates().getMimeType());
assertEquals("UTF-8", result.getTemplating().getTemplates().getEncoding());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result><script type=\"evil/madness\">horror & screams</script></result>\n", result);
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class FederationSearcherTestCase method testNoCloning.
@Test
public void testNoCloning() {
String sourceName = "cloningcheck";
Query query = new Query(QueryTestCase.httpEncode("?query=test&sources=" + sourceName));
addChained(new QueryCheckSearcher(query), sourceName);
addChained(new MockSearcher(), "mySource1");
Chain<Searcher> mainChain = new Chain<>("default", createStrictFederationSearcher());
Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(query);
HitGroup h = (HitGroup) result.hits().get(0);
assertNull(h.getErrorHit());
assertSame(QueryCheckSearcher.OK, h.get(0).getField(QueryCheckSearcher.STATUS));
mainChain = new Chain<>("default", createFederationSearcher());
result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(query);
h = (HitGroup) result.hits().get(0);
assertSame(QueryCheckSearcher.FEDERATION_SEARCHER_HAS_CLONED_THE_QUERY, h.getError().getDetailedMessage());
query = new Query(QueryTestCase.httpEncode("?query=test&sources=" + sourceName + ",mySource1"));
addChained(new QueryCheckSearcher(query), sourceName);
result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(query);
h = (HitGroup) result.hits().get(0);
assertEquals("source:" + sourceName, h.getId().stringValue());
assertSame(QueryCheckSearcher.FEDERATION_SEARCHER_HAS_CLONED_THE_QUERY, h.getError().getDetailedMessage());
assertEquals("source:mySource1", result.hits().get(1).getId().stringValue());
}
Aggregations