Description
Currently, JacksonHandle implements SearchReadHandle. Will JacksonParserHandle and JacksonDatabindHandle implement the same so that they can be used in bulk search?
Here is a test method that uses JacksonHandle in a bulk search. Was looking for a similar functionality in the other two handlers.
When JacksonParserHandle was used (in place of JacksonHandle in the snippet below), the Eclipse Debugger gave a "com.sun.jdi.InvocationException occurred invoking method." exception after a few seconds of delay. Was able to see the following meta-data for a couple of seconds and then handler got the exception.
{"snippet-format":"snippet","total":0,"start":1,"page-length":25,"results":[],"metrics":{"query-resolution-time":"PT0S","snippet-resolution-time":"PT0S","total-time":"PT0S"}}
This is test method from class "TestBulkSearchEWithQBE" in the test-complete package, which uses JacksonHandle.
Sample snippet from the method (Complete method given below)
JacksonHandle sh = new JacksonHandle();
DocumentPage page;
long pageNo=1;
do{
count=0;
page = docMgr.search(qd, pageNo,sh);
public void testBulkSearchQBEWithJSONResponseFormat() throws IOException, ParserConfigurationException, SAXException, TransformerException {
int count;
//Creating a xml document manager for bulk search
XMLDocumentManager docMgr = client.newXMLDocumentManager();
//using QBE for query definition and set the search criteria
QueryManager queryMgr = client.newQueryManager();
String queryAsString = "{\"$query\": { \"says\": {\"$word\":\"woof\",\"$exact\": false}}}";
RawQueryByExampleDefinition qd = queryMgr.newRawQueryByExampleDefinition(new StringHandle(queryAsString).withFormat(Format.JSON));
// set document manager level settings for search response
docMgr.setPageLength(25);
docMgr.setSearchView(QueryView.RESULTS);
docMgr.setResponseFormat(Format.JSON);
// Search for documents where content has bar and get first result record, get search handle on it,Use DOMHandle to read results
JacksonHandle sh = new JacksonHandle();
DocumentPage page;
long pageNo=1;
do{
count=0;
page = docMgr.search(qd, pageNo,sh);
if(pageNo >1){
assertFalse("Is this first Page", page.isFirstPage());
assertTrue("Is page has previous page ?",page.hasPreviousPage());
}
while(page.hasNext()){
DocumentRecord rec = page.next();
rec.getFormat();
validateRecord(rec,Format.JSON);
System.out.println(rec.getContent(new StringHandle()).get().toString());
count++;
}
assertTrue("Page start in results and on page",sh.get().get("start").asLong() == page.getStart());
assertEquals("document count", page.size(),count);
// assertEquals("Page Number #",pageNo,page.getPageNumber());
pageNo = pageNo + page.getPageSize();
}while(!page.isLastPage() && page.hasContent() );
assertEquals("page count is ",5,page.getTotalPages());
assertTrue("Page has previous page ?",page.hasPreviousPage());
assertEquals("page size", 25,page.getPageSize());
assertEquals("document count", 102,page.getTotalSize());
}