List of usage examples for org.apache.solr.client.solrj SolrClient commit
public UpdateResponse commit() throws SolrServerException, IOException
From source file:se.uu.ub.cora.solrindex.SolrRecordIndexer.java
License:Open Source License
private void tryToDeleteFromIndex(String type, String id) throws SolrServerException, IOException { SolrClient solrClient = solrClientProvider.getSolrClient(); solrClient.deleteById(type + "_" + id); solrClient.commit(); }
From source file:uk.bl.wa.annotation.Annotator.java
License:Open Source License
private static void searchAndApplyAnnotations(Annotations ann, SurtPrefixSet oaSurts, String solrServer) throws SolrServerException, URISyntaxException, IOException { // Connect to solr: SolrClient solr = new HttpSolrClient(solrServer); // Set up annotator: Annotator anr = new Annotator(ann, oaSurts); // Loop over URL known to ACT: for (String scope : ann.getCollections().keySet()) { if ("resource".equals(scope)) { // Search for all matching URLs in SOLR: for (String uriKey : ann.getCollections().get(scope).keySet()) { LOG.info("Looking for URL: " + uriKey); SolrQuery parameters = new SolrQuery(); parameters.set("q", "url:" + ClientUtils.escapeQueryChars(uriKey)); searchAndApplyAnnotations(anr, solr, parameters); }/*from www. ja va2s . c o m*/ } else if ("root".equals(scope)) { // Search for all matching URLs in SOLR: for (String uriKey : ann.getCollections().get(scope).keySet()) { LOG.info("Looking for URLs starting with: " + uriKey); SolrQuery parameters = new SolrQuery(); parameters.set("q", "url:" + ClientUtils.escapeQueryChars(uriKey) + "*"); searchAndApplyAnnotations(anr, solr, parameters); } } else { LOG.warn("Ignoring annotations scoped as: " + scope); } } // And commit: solr.commit(); }