Last active
July 22, 2016 17:05
-
-
Save snippet-java/51348316bf853f515e7a5fd638e00367 to your computer and use it in GitHub Desktop.
Retrieve and Rank Java Snippets
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
// |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
SolrClusterOptions options = new SolrClusterOptions("My cluster", 1); | |
SolrCluster cluster = service.createSolrCluster(options); | |
System.out.println("SolrCluster: " + cluster); | |
// wait until the cluster is available | |
while (cluster.getStatus() == Status.NOT_AVAILABLE) { | |
Thread.sleep(10000); // sleep 10 seconds | |
cluster = service.getSolrCluster(cluster.getId()); | |
System.out.println("SolrCluster status: " + cluster.getStatus()); | |
System.out.println("SolrCluster ID: " + cluster.getId()); | |
} | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
SolrClusterList clusters = service.getSolrClusters(); | |
System.out.println(clusters); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
System.out.println(service.getSolrCluster("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6")); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
service.deleteSolrCluster("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6"); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
File configZip = new File("/configs/example_config.zip"); | |
service.uploadSolrClusterConfigurationZip("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6", | |
"example_config", configZip); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
System.out.println(service.getSolrClusterConfigurations("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6")); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
Path FROM = service.getSolrClusterConfigurationZip("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6", "example_config"); | |
Path TO = Paths.get("."); | |
CopyOption[] options = new CopyOption[]{ | |
StandardCopyOption.REPLACE_EXISTING, | |
StandardCopyOption.COPY_ATTRIBUTES | |
}; | |
Files.copy(FROM, TO, options); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
service.deleteSolrClusterConfiguration("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6", "example_config"); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
CollectionAdminRequest.Create createCollectionRequest = | |
new CollectionAdminRequest.Create(); | |
createCollectionRequest.setCollectionName("example_collection"); | |
createCollectionRequest.setConfigName("example_config"); | |
System.out.println("Creating collection..."); | |
CollectionAdminResponse response = createCollectionRequest.process(solrClient); | |
if (!response.isSuccess()) { | |
System.out.println(response.getErrorMessages()); | |
throw new IllegalStateException("Failed to create collection: " | |
+ response.getErrorMessages().toString()); | |
} | |
System.out.println("Collection created."); | |
System.out.println(response); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
cluster.deleteCollection("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6", "example_collection", "json"); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
SolrInputDocument newdoc = new SolrInputDocument(); | |
document.addField("id", 1); | |
document.addField("author", "brenckman,m."); | |
document.addField("bibliography", "j. ae. scs. 25, 1958, 324."); | |
document.addField("body", ""experimental investigation of the aerodynamics of a wing in a slipstream . an experimental study of a wing in a propeller slipstream was made in order to determine the spanwise distribution of the lift increase due to slipstream at different angles of attack of the wing and at different free stream to slipstream velocity ratios . the results were intended in part as an evaluation basis for different theoretical treatments of this problem . the comparative span loading curves, together with supporting evidence, showed that a substantial part of the lift increment produced by the slipstream was due to a /destalling/ or boundary-layer-control effect . the integrated remaining lift increment, after subtracting this destalling lift, was found to agree well with a potential flow theory . an empirical evaluation of the destalling effects was made for the specific configuration of the experiment ."); | |
document.addField("title", ""experimental investigation of the aerodynamics of a wing in a slipstream .") | |
System.out.println("Indexing document..."); | |
UpdateResponse addResponse = solrClient.add("example_collection", newdoc); | |
System.out.println(addResponse); | |
// Commit the document to the index so that it will be available for searching. | |
solrClient.commit("example_collection"); | |
System.out.println("Indexed and committed document."); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
HttpSolrClient solrClient = new HttpSolrClient; | |
solrClient = getSolrClient(service.getSolrUrl("scfaaf8903_02c1_4297_84c6_76b79537d849"), "{username}","{password}"); | |
SolrQuery query = new SolrQuery("*:*"); | |
QueryResponse response = solrClient.query("example_collection", query); | |
System.out.println(response); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
Ranker ranker = service.createRanker("ranker1", "./training_data.csv"); | |
System.out.println(ranker); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
List<String> rankers = service.getRankers(); | |
System.out.println(rankers); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
Ranker ranker = service.getRankerStatus("B2E325-rank-67"); | |
System.out.println(ranker); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
service.deleteRanker("B2E325-rank-67"); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
Ranking ranking = service.rank("B2E325-rank-67", "./answer.csv"); | |
System.out.println(ranking); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND 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); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
System.out.println(service.getSolrClusterStats("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6")); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
service.resizeCluster("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6", "2"); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
service.pollResizeOperationStatus("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6"); | |
} | |
} |
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
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.*; | |
import com.ibm.watson.developer_cloud.retrieve_and_rank.v1.model.*; | |
import java.io.*;import java.util.*; | |
public class Example { | |
public static void main(String args[]) { | |
RetrieveAndRank service = new RetrieveAndRank(); | |
service.setEndPoint("https://watson-api-explorer.mybluemix.net/retrieve-and-rank/api"); // SET YOUR URL | |
//service.setUsernameAndPassword(username,password); // SET YOUR USERNAME AND PASSWORD | |
// missing configuration name | |
Path FROM = service.getSolrClusterConfigurationZip("sc1ca23733_faa8_49ce_b3b6_dc3e193264c6", ""); | |
Path TO = Paths.get("."); | |
CopyOption[] options = new CopyOption[]{ | |
StandardCopyOption.REPLACE_EXISTING, | |
StandardCopyOption.COPY_ATTRIBUTES | |
}; | |
Files.copy(FROM, TO, options); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment