Created
June 21, 2017 07:26
-
-
Save DerSchimi/ef85117b33ecc30c8494ca1b6f4fa852 to your computer and use it in GitHub Desktop.
groovy solr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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