本文整理匯總了Java中org.apache.solr.client.solrj.response.QueryResponse.getBeans方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryResponse.getBeans方法的具體用法?Java QueryResponse.getBeans怎麽用?Java QueryResponse.getBeans使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.solr.client.solrj.response.QueryResponse
的用法示例。
在下文中一共展示了QueryResponse.getBeans方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: exportBatchWise
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
private static void exportBatchWise(SolrServer server, File exportFolder, int batchSize, int offset, Gson gson) throws SolrServerException, IOException {
QueryResponse response = SolrHandler.searchSolrIndex(server, "*:*", batchSize, offset);
List<BookEntry> bookEntries = response.getBeans(BookEntry.class);
System.out.println("Retrieved " + (bookEntries.size() + offset) + " of " + response.getResults().getNumFound());
for(BookEntry bookEntry : bookEntries) {
String bookTitle = bookEntry.getTitle();
bookTitle = bookTitle.replaceAll(":", " ");
File bookFolder = new File(exportFolder, bookEntry.getAuthor() + "-" + bookTitle);
bookFolder.mkdirs();
if(bookEntry.getFile() != null && bookEntry.getCover() != null) {
File bookData = new File(bookFolder, bookEntry.getAuthor() + "-" + bookTitle + ".mobi");
Files.write(bookData.toPath(), bookEntry.getFile(), StandardOpenOption.CREATE_NEW);
File coverData = new File(bookFolder, bookEntry.getAuthor() + "-" + bookTitle + ".jpg");
Files.write(coverData.toPath(), bookEntry.getCover(), StandardOpenOption.CREATE_NEW);
Date dreleaseDate = null;
if (bookEntry.getReleaseDate()!=null) {
DateTime dtReleaseDate = DateTime.parse(bookEntry.getReleaseDate(), DateTimeFormat.forPattern("YYYY-MM-dd"));
dtReleaseDate = new DateTime(dtReleaseDate, DateTimeZone.UTC);
dreleaseDate = dtReleaseDate.toDate();
}
DateTime dtUploadDate = new DateTime(DateTimeZone.UTC);
File metaDataFile = new File(bookFolder, bookEntry.getAuthor() + "-" + bookTitle + ".json");
String[] viewed = {};
BookMetaData metaData = new BookMetaData(bookEntry.getAuthor(), bookEntry.getTitle(), bookEntry.getIsbn(),
bookEntry.getPublisher(), bookEntry.getDescription(), bookEntry.getLanguage(),
dreleaseDate, bookEntry.getMimeType(),dtUploadDate.toDate(),viewed,bookEntry.getShared());
gson.toJson(metaData);
Files.write(metaDataFile.toPath(), gson.toJson(metaData).getBytes(), StandardOpenOption.CREATE_NEW);
}
}
if(response.getResults().getNumFound() > offset) {
exportBatchWise(server, exportFolder, batchSize, offset + batchSize, gson);
}
}
示例2: createThumbnailForBook
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
public static void createThumbnailForBook(String solrURL, String solrCore, String bookID) throws SolrServerException, IOException {
SolrServer server = SolrHandler.createConnection(solrURL, solrCore);
QueryResponse response = SolrHandler.searchSolrIndex(server, "id:"+bookID, 1, 0);
List<BookEntry> bookEntries = response.getBeans(BookEntry.class);
System.out.println("Retrieved " + (bookEntries.size()) + " of " + response.getResults().getNumFound());
for(BookEntry bookEntry : bookEntries) {
if (bookEntry.getCover() != null) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
Thumbnails.of(new ByteArrayInputStream(bookEntry.getCover()))
.size(130, 200)
.toOutputStream(output);
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", bookEntry.getId());
Map<String, Object> thumbnailData = new HashMap<>();
thumbnailData.put("set", output.toByteArray());
doc.addField("thumbnail", thumbnailData);
Map<String, Object> thumbnailStatus = new HashMap<>();
thumbnailStatus.put("set", "done");
doc.addField("thumbnailgenerated", thumbnailStatus);
server.add(doc);
server.commit();
}
}
}
示例3: convertBatchWise
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
private static void convertBatchWise(SolrServer server,int batchSize, int offset) throws SolrServerException, IOException {
QueryResponse response = SolrHandler.searchSolrIndex(server, "-thumbnailgenerated:done", batchSize, offset);
List<BookEntry> bookEntries = response.getBeans(BookEntry.class);
System.out.println("Retrieved " + (bookEntries.size() + offset) + " of " + response.getResults().getNumFound());
for(BookEntry bookEntry : bookEntries) {
if (bookEntry.getCover() != null) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
Thumbnails.of(new ByteArrayInputStream(bookEntry.getCover()))
.size(130, 200)
.toOutputStream(output);
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", bookEntry.getId());
Map<String, Object> thumbnailData = new HashMap<>();
thumbnailData.put("set", output.toByteArray());
doc.addField("thumbnail", thumbnailData);
Map<String, Object> thumbnailStatus = new HashMap<>();
thumbnailStatus.put("set", "done");
doc.addField("thumbnailgenerated", thumbnailStatus);
server.add(doc);
server.commit();
}
}
response = SolrHandler.searchSolrIndex(server, "-thumbnailgenerated:done", batchSize, offset);
if(response.getResults().getNumFound() > 0) {
convertBatchWise(server, batchSize, 0);
}
}
示例4: searchBooks
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
public void searchBooks(SolrQuery query, boolean reset) {
try {
String user = SecurityUtils.getSubject().getPrincipals().toString();
this.query = query;
if (reset) {
resultLayout.removeAllComponents();
}
query.setStart(resultLayout.getComponentCount());
QueryResponse queryResponse = presenter.searchBooks(query,user);
if (reset) {
resultText.setValue(queryResponse.getResults().getNumFound() + " Ergebnisse mit \"" + appHeader.getSearchText() +"\" gefunden.");
}
List<BookEntry> bookEntries = queryResponse.getBeans(BookEntry.class);
for (BookEntry bookEntry : bookEntries) {
resultLayout.addComponent(createBookCoverLayout(bookEntry));
}
showMore.setEnabled(queryResponse.getResults().getNumFound() > resultLayout.getComponentCount());
} catch (SolrServerException ex) {
Notification.show(ex.getMessage(), Notification.Type.WARNING_MESSAGE);
logger.error(ex, ex);
}
}
示例5: getBookDetail
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
public List<BookEntry> getBookDetail(String bookID) throws SolrServerException {
SolrServer solr = null;
try {
solr = bookeryService.getSolrConnection();
} catch (IOException ex) {
throw new SolrServerException(ex.getMessage());
}
SolrQuery query = new SolrQuery();
query.setQuery("id:"+bookID);
query.setRows(1);
query.setFields("id,author,title,isbn,publisher,description,language,releaseDate,likes,downloadcount,uploader,viewed,shared,cover,thumbnail,thumbnailgenerated,likedby");
QueryResponse rsp = solr.query(query);
return rsp.getBeans(BookEntry.class);
}
示例6: getEpubBook
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
public List<BookEntry> getEpubBook(String bookID) throws SolrServerException {
SolrServer solr = null;
try {
solr = bookeryService.getSolrConnection();
} catch (IOException ex) {
throw new SolrServerException(ex.getMessage());
}
SolrQuery query = new SolrQuery();
query.setQuery("id:"+bookID);
query.setRows(1);
query.setFields("id,epub");
QueryResponse rsp = solr.query(query);
return rsp.getBeans(BookEntry.class);
}
示例7: getMobiFormat
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
public List<BookEntry> getMobiFormat(String bookID) throws SolrServerException {
SolrServer solr = null;
try {
solr = bookeryService.getSolrConnection();
} catch (IOException ex) {
throw new SolrServerException(ex.getMessage());
}
SolrQuery query = new SolrQuery();
query.setQuery("id:"+bookID);
query.setRows(1);
query.setFields("id,mobi");
QueryResponse rsp = solr.query(query);
return rsp.getBeans(BookEntry.class);
}
示例8: processResults
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
private static void processResults(SearchQuery searchQuery, QueryResponse response) {
List<SearchItem> items = response.getBeans(SearchItem.class);
searchQuery.setResults(items);
for (SearchItem item : items) {
Map<String, List<String>> highlights = response.getHighlighting().get(item.getId());
String summary = getHighlights(highlights, "summary");
item.setSummary(summary != null ? summary : ("..." + getHighlights(highlights, "body") + "..."));
}
searchQuery.setTotal(response.getResults().getNumFound());
}
示例9: findProductsByCustom
import org.apache.solr.client.solrj.response.QueryResponse; //導入方法依賴的package包/類
public PageProductResponse findProductsByCustom(Product product){
SolrQuery sq = new SolrQuery();
sq.set("q","goods_name:黃瓜花");
sq.set("fl","stores_name", "id", "goods_name");
QueryResponse queryResponse = null;//solrTemplate.querySolrByCustomDefine(sq);
List<Product> productList = queryResponse.getBeans(Product.class);
PageProductResponse pageModel = new PageProductResponse();
pageModel.setTotalPages(queryResponse.getResults().getNumFound());
return pageModel;
}