Skip to content

Instantly share code, notes, and snippets.

@DerSchimi
Created June 21, 2017 07:26
Show Gist options
  • Save DerSchimi/ef85117b33ecc30c8494ca1b6f4fa852 to your computer and use it in GitHub Desktop.
Save DerSchimi/ef85117b33ecc30c8494ca1b6f4fa852 to your computer and use it in GitHub Desktop.
groovy solr
@Grab(group='org.apache.solr', module='solr-solrj', version='4.5.0')
import org.apache.solr.client.solrj.impl.HttpSolrServer
import org.apache.solr.common.SolrInputDocument
import org.apache.solr.common.SolrDocument;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.client.solrj.response.UpdateResponse;
String url = "http://<host>:<port>/solr/<collection>"
def server = new HttpSolrServer( url );
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
QueryResponse response = server.query(query);
SolrDocumentList docs = response.getResults();
docs.each{
println "entry:" +it;
}
server.close();
println 'done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment