SEARCH-2460: Additional methods to perform operations and queries in SOLR (#99)

This commit is contained in:
Angel Borroy
2020-11-13 09:54:13 +01:00
committed by GitHub
parent 10b427209d
commit 2c149b412e

View File

@@ -67,6 +67,17 @@ public class SolrAPI extends ModelRequest<SolrAPI>
return restWrapper.processTextResponse(request);
}
/**
* Executes an action (like "delete") on SOLR alfresco core
* @param urlActionPath some action name (like "delete")
* @param queryBody parameters for the action
*/
public RestTextResponse postAction(String urlActionPath, String queryBody) throws Exception
{
RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, queryBody, urlActionPath);
return restWrapper.processTextResponse(request);
}
public RestTextResponse getSelectQuery() throws Exception
{
List<Header> headers = new ArrayList<Header>();
@@ -77,4 +88,19 @@ public class SolrAPI extends ModelRequest<SolrAPI>
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "select?q={parameters}", restWrapper.getParameters());
return restWrapper.processTextResponse(request);
}
/**
* Executes a query in SOLR using JSON format for the results
*/
public RestTextResponse getSelectQueryJson() throws Exception
{
List<Header> headers = new ArrayList<Header>();
headers.add(new Header("Content-Type", "application/json"));
Headers header = new Headers(headers);
restWrapper.setResponseHeaders(header);
restWrapper.configureRequestSpec().setUrlEncodingEnabled(false);
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "select?q={parameters}&wt=json", restWrapper.getParameters());
return restWrapper.processTextResponse(request);
}
}