Skip to content

Commit 26c1f94

Browse files
committed
Add method to get the Solr url form R&R
1 parent f62034d commit 26c1f94

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/main/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRank.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public class RetrieveAndRank extends WatsonService implements ClusterLifecycleMa
7777
private static final String PATH_CREATE_RANKER = "/v1/rankers";
7878

7979
private static final String PATH_GET_SOLR_CLUSTER = "/v1/solr_clusters/%s";
80+
private static final String PATH_SOLR = "/v1/solr_clusters/%s/solr";
8081
private static final String PATH_RANK = "/v1/rankers/%s/rank";
8182
private static final String PATH_RANKER = "/v1/rankers/%s";
8283
private static final String PATH_RANKERS = "/v1/rankers";
@@ -313,9 +314,19 @@ public SolrClusterList getSolrClusters() {
313314
return executeRequest(request, SolrClusterList.class);
314315
}
315316

317+
/**
318+
* This URL can be used with the SolrJ library to access Solr functionality.
319+
*
320+
* @param solrClusterId the ID of the Solr cluster to connect to
321+
* @return URL to access Solr
322+
*/
323+
public String getSolrUrl(String solrClusterId) {
324+
return String.format(PATH_SOLR, solrClusterId);
325+
}
326+
316327
/**
317328
* Gets and returns the ranked answers.
318-
*
329+
*
319330
* @param rankerID The ranker ID
320331
* @param answers The CSV file that contains the search results that you want to rank.
321332
* @param topAnswers The number of top answers needed, default is 10

src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankIntegrationTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ public void testGetSolrClusters() {
185185
assertTrue(!clusters.getSolrClusters().isEmpty());
186186
}
187187

188+
@Test
189+
public void testGetSolrUrl() {
190+
final String solrUrl = service.getSolrUrl(clusterId);
191+
final String expectedUrl = "/solr_clusters/" + clusterId + "/solr";
192+
assertTrue(solrUrl.endsWith(expectedUrl));
193+
}
194+
188195
@Test
189196
public void testUploadAndDeleteSolrClusterConfigurationDirectory() {
190197
try {

0 commit comments

Comments
 (0)