Revision 54799
Added by Claudio Atzori about 5 years ago
DedupIndexDAO.java | ||
---|---|---|
31 | 31 |
import org.apache.commons.lang.StringUtils; |
32 | 32 |
import org.apache.commons.logging.Log; |
33 | 33 |
import org.apache.commons.logging.LogFactory; |
34 |
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
|
34 |
import org.apache.solr.client.solrj.impl.CloudSolrServer;
|
|
35 | 35 |
import org.apache.solr.common.SolrInputDocument; |
36 | 36 |
import org.dom4j.DocumentException; |
37 | 37 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
119 | 119 |
|
120 | 120 |
log.info("starting index update"); |
121 | 121 |
|
122 |
try(final CloudSolrClient solrServer = getSolrServer()) { |
|
122 |
final CloudSolrServer solrServer = getSolrServer(); |
|
123 |
try { |
|
123 | 124 |
final SolrProtoMapper mapper = initProtoMapper(); |
124 | 125 |
|
125 | 126 |
final Function<Oaf, SolrInputDocument> oaf2solr = oaf2solr(group, mapper); |
... | ... | |
154 | 155 |
commitStatus = solrServer.commit().getStatus(); |
155 | 156 |
|
156 | 157 |
log.debug("solr commit status: " + commitStatus); |
158 |
} finally { |
|
159 |
solrServer.shutdown(); |
|
157 | 160 |
} |
158 | 161 |
|
159 | 162 |
return (addStatus == 0) && (commitStatus == 0); |
... | ... | |
190 | 193 |
+ "']//LAYOUT[@name='index']/FIELDS")); |
191 | 194 |
} |
192 | 195 |
|
193 |
private CloudSolrClient getSolrServer() {
|
|
196 |
private CloudSolrServer getSolrServer() {
|
|
194 | 197 |
final String zk = getIndexSolrUrlZk(); |
195 | 198 |
log.info(String.format("initializing solr client for collection %s, zk url: %s", dedupIndexCollection, zk)); |
196 |
final CloudSolrClient solrServer = new CloudSolrClient.Builder().withZkHost(zk).build();
|
|
199 |
final CloudSolrServer solrServer = new CloudSolrServer(zk);
|
|
197 | 200 |
solrServer.setDefaultCollection(dedupIndexCollection); |
198 | 201 |
|
199 | 202 |
return solrServer; |
Also available in: Unified diff
using solr 4.9