1. org.apache.solr.client.solrj.impl.HttpSolrServer 修改为:org.apache.solr.client.solrj.impl.HttpSolrClient
2. SolrClient solrClient = new CloudSolrClient(zkHost);
new方式在新版已经被废弃,采用新版链式赋值法进行创建对象
SolrClient solrClient = new CloudSolrClient.Builder().withZkHost(Arrays.asList(zkHost.split(","))).build();
3. solrClient = new ConcurrentUpdateSolrClient(url, queueSize, threadCount);
采用链式赋值法
solrClient = new ConcurrentUpdateSolrClient.Builder(url).withQueueSize(queueSize).withThreadCount(threadCount).build();
4. solrClient = new HttpSolrClient(baseURL);
采用链式赋值法
solrClient = new HttpSolrClient.Builder(baseURL).build();
5. ClusterState clusterState = zkStateReader.getClusterState();
Map map = clusterState.getActiveSlicesMap(collection);
api已经将getActiveSlicesMap废弃
map = clusterState.getCollection(collection).getActiveSlicesMap();
6. List collections = zkStateReader.getAllCollections();
api已经将getAllCollections()废弃掉
Map map = zkStateReader.getClusterState().getCollectionsMap();
7. Collection slices = clusterState.getSlices(Collection);
api已经将getSlices(collection)废弃,采用更加方便、安全的中间类DocCollection
DocCollection docCollection = clusterState.getCollection(collection);
Collection slices = docCollection.getActiveSlices();
8. CollectionAdminRequest.Create req = new CollectionAdminRequest.Create();
req.setCollectionName(name);
req.setNumShards(numShards);
req.setConfigName(cluster);
req.setCreateNodeSet(getNodeSet(cluster));
req.setReplicationFactor(numReplicas);
修改为链式赋值法
CollectionAdminRequest.Create req = CollectionAdminRequest.createCollection(name, cluster, numShards, numReplicas);
9. CollectionAdminRequest.Delete req = new CollectionAdminRequest.Delete();
api已将这种创建方式废弃
CollectionAdminRequest.Delete req = CollectionAdminRequest.deleteCollection(name);
10. CollectionAdminRequest.CreateAlias req = new CollectionAdminRequest.CreateAlias();
api已经将这种创建方式废弃
CollectionAdminRequest.CreateAlias req = CollectionAdminRequest.createAlias(name, collections);
11. CollectionAdminRequest.DeleteAlias req = new CollectionAdminRequest.deleteAlias();
api已经将这种创建方式废弃
CollectionAdminRequest.DeleteAlias req = CollectionAdminRequest.deleteAlias(name);
12. SolrInputDocument inputDocument = ClientUtils.toSolrInputDocument(solrDocument);
将SolrDocument 转换为 SolrInputDocument 的方法从ClientUtils中移除了.从solr-5.5之后就将此方法移除,代码中要想使用此类似功能,需要自己添加方法实现
/**
* 将SolrDocument转换为SolrInputDocument,原底层提供的方法从solr5.5之后被废弃掉了
* add by liangyongxing
* @param solrDocument
* @createTime 2017-02-21
* @return
*/
public static SolrInputDocument toSolrInputDocument(SolrDocument solrDocument) {
SolrInputDocument doc = new SolrInputDocument();
for (String name : solrDocument.getFieldNames()) {
doc.addField(name, solrDocument.getFieldValue(name));
}
return doc;
}