protected SolrDocumentList getSolrDocumentByUUIDs(List<String> uuids) { String operand = "OR"; SolrDocumentList solrDocumentList = null; StringBuffer sb = new StringBuffer(); sb.append("("); for (String uuid : uuids) { sb.append("("); sb.append(uuid); sb.append(")"); sb.append(operand); } String queryString = sb.substring(0, sb.length() - operand.length()) + ")"; SolrQuery query = new SolrQuery(); SolrDocument solrDocument = null; try { SolrServer server = SolrServerManager.getInstance().getSolrServer(); QueryResponse response = null; query.setQuery("id:" + queryString); response = server.query(query); solrDocumentList = response.getResults(); } catch (SolrServerException e) { LOG.info("Exception :", e); throw new DocstoreIndexException(); } return solrDocumentList; }
protected void indexAndDelete( List<SolrInputDocument> solrDocs, List<String> idsToDelete, boolean isCommit) { synchronized (this.getClass()) { SolrServer solr = null; try { solr = SolrServerManager.getInstance().getSolrServer(); if (CollectionUtils.isNotEmpty(solrDocs)) { UpdateResponse response = solr.add(solrDocs); } // deleting document which contains operation delete delete(idsToDelete, solr); if (isCommit) { try { commitRecordsToSolr(solr); } catch (HttpSolrServer.RemoteSolrException e) { lastCommitTime = System.currentTimeMillis(); if (e.getMessage().startsWith(MAX_WARM_SEARCH)) { LOG.warn(e.getMessage()); } else { throw e; } } } } catch (Exception e) { LOG.info("Exception :", e); rollback(solr); throw new DocstoreIndexException(e); } } }
protected void indexSolrDocuments(List<SolrInputDocument> solrDocs, boolean isCommit) { synchronized (this.getClass()) { SolrServer solr = null; try { solr = SolrServerManager.getInstance().getSolrServer(); UpdateResponse response = solr.add(solrDocs); if (isCommit) { try { commitRecordsToSolr(solr); } catch (HttpSolrServer.RemoteSolrException e) { lastCommitTime = System.currentTimeMillis(); if (e.getMessage().startsWith(MAX_WARM_SEARCH)) { LOG.warn(e.getMessage()); } else { throw e; } } } } catch (Exception e) { LOG.info("Exception :", e); rollback(solr); throw new DocstoreIndexException(e); } } }
/** * process documents and updating parent documents * * @param id * @param solrInputDocuments */ public void processDelete(String id, List<SolrInputDocument> solrInputDocuments) { try { SolrServer server = SolrServerManager.getInstance().getSolrServer(); processRecord(server, id, solrInputDocuments); } catch (SolrServerException e) { LOG.info("Exception :", e); throw new DocstoreIndexException(); } catch (IOException e) { LOG.info("Exception :", e); throw new DocstoreIndexException(); } }
@Override public void deleteBatch(String id) { try { SolrServer server = SolrServerManager.getInstance().getSolrServer(); deleteRecordInSolr(server, id); } catch (SolrServerException e) { LOG.info("Exception :", e); throw new DocstoreIndexException(); } catch (IOException e) { LOG.info("Exception :", e); throw new DocstoreIndexException(); } }
public List<SolrDocument> getSolrDocumentBySolrId(String uniqueId) { QueryResponse response = null; String result = null; try { String args = "(" + UNIQUE_ID + ":" + uniqueId + ")"; SolrServer solr = SolrServerManager.getInstance().getSolrServer(); SolrQuery query = new SolrQuery(); query.setQuery(args); response = solr.query(query); } catch (Exception e) { LOG.info("Exception :", e); throw new DocstoreIndexException(e.getMessage()); } return response.getResults(); }
protected SolrDocument getSolrDocumentByUUID(String identifier) { SolrQuery query = new SolrQuery(); SolrDocument solrDocument = null; SolrServer server = null; try { server = SolrServerManager.getInstance().getSolrServer(); QueryResponse response = null; query.setQuery("id:" + identifier); response = server.query(query); solrDocument = response.getResults().get(0); } catch (SolrServerException e) { LOG.info("Exception :", e); throw new DocstoreIndexException(e.getMessage()); } return solrDocument; }