List of usage examples for org.apache.solr.client.solrj.request GenericSolrRequest GenericSolrRequest
public GenericSolrRequest(METHOD m, String path, SolrParams params)
From source file:fr.gael.dhus.search.SolrDao.java
License:Open Source License
/** * Set the given properties and values using the config API. * @param props properties to set.//w ww .j ava2s. c o m * @throws IOException network error. * @throws SolrServerException solr error. */ public void setProperties(Map<String, String> props) throws SolrServerException, IOException { // Solrj does not support the config API yet. StringBuilder command = new StringBuilder("{\"set-property\": {"); for (Map.Entry<String, String> entry : props.entrySet()) { command.append('"').append(entry.getKey()).append('"').append(':'); command.append(entry.getValue()).append(','); } command.setLength(command.length() - 1); // remove last comma command.append("}}"); GenericSolrRequest rq = new GenericSolrRequest(SolrRequest.METHOD.POST, "/config", null); ContentStream content = new ContentStreamBase.StringStream(command.toString()); rq.setContentStreams(Collections.singleton(content)); rq.process(solrClient); }
From source file:fr.gael.dhus.search.SolrDao.java
License:Open Source License
/** * Unset the given properties that have been previously set with {@link #setProperties(Map)}. * @param props properties to unset./*from w w w . j a v a 2 s . c o m*/ * @throws IOException network error. * @throws SolrServerException solr error. */ public void unsetProperties(Set<String> props) throws SolrServerException, IOException { // Solrj does not support the config API yet. StringBuilder command = new StringBuilder("{\"unset-property\": ["); for (String prop : props) { command.append('"').append(prop).append('"').append(','); } command.setLength(command.length() - 1); // remove last comma command.append("]}"); GenericSolrRequest rq = new GenericSolrRequest(SolrRequest.METHOD.POST, "/config", null); ContentStream content = new ContentStreamBase.StringStream(command.toString()); rq.setContentStreams(Collections.singleton(content)); rq.process(solrClient); }