本文整理汇总了Java中org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer.add方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentUpdateSolrServer.add方法的具体用法?Java ConcurrentUpdateSolrServer.add怎么用?Java ConcurrentUpdateSolrServer.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer
的用法示例。
在下文中一共展示了ConcurrentUpdateSolrServer.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: concurrentUpdateSolrServer
import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer; //导入方法依赖的package包/类
/**
* Uses the {@link HttpSolrServer} to index some data to Solr.
*
* @throws Exception in case of I/O or index failure.
*/
@Test
public void concurrentUpdateSolrServer() throws Exception {
final int bufferSize = 2; // commit each 2 albums
final int threadsNo = 2; // Use two indexer threads
// 1. Create a new instance of HttpSolrServer
// Note that we are simply repeating the same server three times, in order to "simulate" a
// scenario with three searchers.
// In a real context we would have three different urls.
solr = new ConcurrentUpdateSolrServer(SOLR_URI, bufferSize, threadsNo);
// 2. Create some data
final List<SolrInputDocument> albums = sampleData();
// 3. Add those data
solr.add(albums);
// 4. Commit
solr.commit();
// 5. Verify
verify();
}
示例2: indexData
import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer; //导入方法依赖的package包/类
/**
* Indexes a set of sample documents.
*
* @throws SolrServerException in case of Solr internal failure,
* @throws IOException in case of I/O failure.
*/
@BeforeClass
public static void indexData() throws SolrServerException, IOException {
// 1. Create a proxy indexer
INDEXER = new ConcurrentUpdateSolrServer(SOLR_URI, 2, 1);
// 2. Index sample data
INDEXER.add(sampleData());
// 3. Commit changes
INDEXER.commit();
// 4. Create a proxy searcher
SEARCHER = new HttpSolrServer(SOLR_URI);
}