0

Does anyone ever used the Retrieve & Rank service with Java SDK (Rank service particularly) ?

I want to understand how it works because some points seem me not logical :

  • What is the difference between the Java approach, where we must execute a search query with Apache Solr, and then call the method rank; and the CURL approach, where we just have to run a single query?
  • Why the method rank takes a CSV file that contains results from the search query whereas we apparently cannot have the result of a search query in CSV?

I did not find my responses neitheir in this documentation nor in this example.

Thanks for your time.

1 Answer 1

0

I have never used Retrieve and Rank before but by reading the documentation here are my thoughts

  1. I do not think that there any difference between Java approach and CURL. From what I understand Search and rank in curl uses this command

    curl -u "{username}":"{password}" "https://gateway.watsonplatform.net/retrieve-and-rank/api/v1/solr_clusters/sc1ca23733_faa8_49ce_b3b6_dc3e193264c6/solr/example_collection/fcselect?ranker_id=B2E325-rank-67&q=what%20is%20the%20basic%20mechanism%20of%20the%20transonic%20aileron%20buzz&wt=json&fl=id,title"

while in Java

RetrieveAndRank service = new RetrieveAndRank();
service.setUsernameAndPassword("{username}","{password}");
HttpSolrClient solrClient = new HttpSolrClient;
solrClient = getSolrClient(service.getSolrUrl("scfaaf8903_02c1_4297_84c6_76b79537d849"), "{username}","{password}");
SolrQuery query = new SolrQuery("what is the basic mechanism of the transonic aileron buzz");
QueryResponse response = solrClient.query("example_collection", query);
Ranking ranking = service.rank("B2E325-rank-67", response);
System.out.println(ranking);

I think what the curl command would do, at the back end it would fire a search in Solr using the query specified and after the results returned it would rank them. In Java this is done explicitly, instead of having a method queryAndRank you have two methods, one that is going to run in Solr, get the results from there and then forward these results to ranking system.

  1. The search in Solr can return csv.

The CSVResponseWriter can write the list of documents in a response in CSV format.

http://wiki.apache.org/solr/CSVResponseWriter

1
  • Thanks for your response. Unfortunately, the document is outdated because it is not possible to do this : service.rank("B2E325-rank-67", response). Now, we have to do this : service.rank(rankerId, answerCsvFile, topAnswerInteger). And for the second point, it is possible in CURL, but in Java, when i tried to set the parameter wt, it did not work (more details : stackoverflow.com/questions/29015996/…) Jun 27, 2016 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.