當前位置: 首頁>>代碼示例>>Java>>正文


Java SolrClient.close方法代碼示例

本文整理匯總了Java中org.apache.solr.client.solrj.SolrClient.close方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrClient.close方法的具體用法?Java SolrClient.close怎麽用?Java SolrClient.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.solr.client.solrj.SolrClient的用法示例。


在下文中一共展示了SolrClient.close方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shutdownGracefully

import org.apache.solr.client.solrj.SolrClient; //導入方法依賴的package包/類
private void shutdownGracefully(SolrClient client) throws SolrServerException, IOException {
    if (client != null) {
        LOGGER.info("Shutting down solr client: {}", client);
        client.commit(false, false);
        client.close();
    }
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:8,代碼來源:MCRSolrCore.java

示例2: close

import org.apache.solr.client.solrj.SolrClient; //導入方法依賴的package包/類
public void close() throws IOException {
  commit();

  for (SolrClient solrClient : solrClients) {
    solrClient.close();
  }
}
 
開發者ID:jorcox,項目名稱:GeoCrawler,代碼行數:8,代碼來源:SolrIndexWriter.java

示例3: main

import org.apache.solr.client.solrj.SolrClient; //導入方法依賴的package包/類
public static void main(String[] args) throws CorruptIndexException, IOException, SolrServerException {

        if (args.length < 3) {
            System.err.println("Usage: java -Dfile.encoding=UTF8 -Dclient.encoding.override=UTF-8 -Xmx256m -Xms256m -server " + IndexLoader.class.getName()
                    + " </path/to/index> <AutoCompleteSolrUrl> <indexField1,acField1> [indexField2,acField2 ... ]");
            System.exit(0);
        }
        Map<String,String> fieldMap = getFieldMapping(args, 2);
        DirectoryReader reader = DirectoryReader.open(FSDirectory.open(Paths.get(args[0])));
        int docs = reader.maxDoc();
        SolrClient solr = new ConcurrentUpdateSolrClient.Builder(args[1]).withQueueSize(10000).withThreadCount(2).build();
        Set<SolrInputDocument> batch = new HashSet<SolrInputDocument>(1000);
        
        Bits liveDocs = MultiFields.getLiveDocs(reader);
        
        // go through all docs in the index
        for (int i = 0; i < docs; i++) {
            // process doc only if not deleted
            if (liveDocs == null || liveDocs.get(i)) {
                // loop through all fields to be looked at
                SolrInputDocument doc = new SolrInputDocument();
                Iterator<String> iter = fieldMap.keySet().iterator();
                
                boolean phraseFieldEmpty = false;
                
                while (iter.hasNext()) {
                    String indexField = iter.next();
                    String acField = fieldMap.get(indexField);
                    IndexableField field = reader.document(i).getField(indexField);
                    String value = field != null ? reader.document(i).getField(indexField).stringValue() : null;
                    
                    if (field != null && value != null && !value.isEmpty()) {
                      doc.addField(acField, value);
                    } else {
                      // not very relevant piece of info
                      // System.err.println("Field is null or empty, skipping: " + indexField);
                      
                      if (acField.equalsIgnoreCase("phrase")) {
                        System.err.println("Since AC phrase field would be null, this doc will not be created: " + reader.document(i));
                        phraseFieldEmpty = true;
                        break;
                      }
                    }
                }

                if (!phraseFieldEmpty) {
                  solr.add(doc);
                  if (docs % 1000 == 0) {
                    System.out.println("Docs: " + docs);
                  }
                }
            }
        }
        if (!batch.isEmpty())
            solr.add(batch);
        reader.close();
        System.out.println("Optimizing...");
        solr.optimize();
        solr.close();
    }
 
開發者ID:sematext,項目名稱:solr-autocomplete,代碼行數:61,代碼來源:IndexLoader.java

示例4: doUninstall

import org.apache.solr.client.solrj.SolrClient; //導入方法依賴的package包/類
@Override
protected void doUninstall() throws Exception {
    SolrClient sc = solrSimilarityService.getSolrClient();
    if (sc != null) sc.close();
    Files.walkFileTree(solrHomeFolder, new TreeDelete());
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:7,代碼來源:SolrSimilarityGenerator.java

示例5: destroy

import org.apache.solr.client.solrj.SolrClient; //導入方法依賴的package包/類
@Override
public void destroy() throws Exception {
    logger.info("Destroying solr plugin!");
    SolrClient sc = solrSimilarityService.getSolrClient();
    if (sc != null) sc.close();
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:7,代碼來源:SolrSimilarityGenerator.java

示例6: shutdownServer

import org.apache.solr.client.solrj.SolrClient; //導入方法依賴的package包/類
private void shutdownServer(SolrClient server) throws IOException {
    if (server != null) {
        LOG.info("Shutting down solr server: {}", server);
        server.close();
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:7,代碼來源:SolrComponent.java


注:本文中的org.apache.solr.client.solrj.SolrClient.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。