We are using the SolrJ client to query documents from Solr. The query that we are building is large and Solr is rejecting the query (with error response 414 URI Too Long
).
However, I can directly call Solr's /query
endpoint and post the query as the body using a POST request. Is there a way to do this using the SolrJ client?
You can use post method in SolrJ using QueryRequest which has options to set HTTP methods.
public QueryResponse query(SolrQuery parameters){
QueryResponse resp=null;
try {
QueryRequest queryRequest=new QueryRequest(parameters);
queryRequest.setMethod(SolrRequest.METHOD.POST);
NamedList nl=solrClient.request(queryRequest);
resp=new QueryResponse(nl, solrClient);
} catch (Exception e) {
e.printStackTrace();
}
return resp;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With