本文整理汇总了Java中org.apache.solr.client.solrj.impl.CloudSolrClient.setParser方法的典型用法代码示例。如果您正苦于以下问题:Java CloudSolrClient.setParser方法的具体用法?Java CloudSolrClient.setParser怎么用?Java CloudSolrClient.setParser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.impl.CloudSolrClient
的用法示例。
在下文中一共展示了CloudSolrClient.setParser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCollections
import org.apache.solr.client.solrj.impl.CloudSolrClient; //导入方法依赖的package包/类
/**
* Get target cores via CollectionsAPI.
*
* @param cloudSolrClient
* @return
*/
public static List<String> getCollections(CloudSolrClient cloudSolrClient) throws SolrServerException, IOException {
List<String> collections = new ArrayList<>();
NoOpResponseParser responseParser = new NoOpResponseParser();
responseParser.setWriterType("json");
cloudSolrClient.setParser(responseParser);
CollectionAdminRequest collectionAdminRequest = new CollectionAdminRequest.List();
NamedList<Object> collectionAdminResponse = cloudSolrClient.request(collectionAdminRequest);
JsonNode collectionsJsonNode = om.readTree((String) collectionAdminResponse.get("response")).get("collections");
for (Iterator<JsonNode> i = collectionsJsonNode.iterator(); i.hasNext(); ) {
String collection = i.next().textValue();
if (!collections.contains(collection)) {
collections.add(collection);
}
}
return collections;
}
示例2: getBaseUrls
import org.apache.solr.client.solrj.impl.CloudSolrClient; //导入方法依赖的package包/类
/**
* Get base urls via CollectionsAPI.
*
* @param cloudSolrClient
* @return
*/
private List<String> getBaseUrls(CloudSolrClient cloudSolrClient) throws SolrServerException, IOException {
List<String> baseUrls = new ArrayList<>();
NoOpResponseParser responseParser = new NoOpResponseParser();
responseParser.setWriterType("json");
cloudSolrClient.setParser(responseParser);
CollectionAdminRequest collectionAdminRequest = new CollectionAdminRequest.ClusterStatus();
NamedList<Object> collectionAdminResponse = cloudSolrClient.request(collectionAdminRequest);
List<JsonNode> baseUrlJsonNode = om.readTree((String) collectionAdminResponse.get("response")).findValues("base_url");
for (Iterator<JsonNode> i = baseUrlJsonNode.iterator(); i.hasNext(); ) {
String baseUrl = i.next().textValue();
if (!baseUrls.contains(baseUrl)) {
baseUrls.add(baseUrl);
}
}
return baseUrls;
}
示例3: fromZookeeperHosts
import org.apache.solr.client.solrj.impl.CloudSolrClient; //导入方法依赖的package包/类
public static SolrClient fromZookeeperHosts(String zkHostsCommaSeparated, String zkChroot) {
CloudSolrClient.Builder b =
new CloudSolrClient.Builder().withZkHost(Arrays.asList(zkHostsCommaSeparated.split(",")));
if (zkChroot != null && zkChroot.length() > 0) {
b.withZkChroot(zkChroot);
}
CloudSolrClient csc = b.build();
csc.setParser(new InputStreamResponseParser("json"));
return csc;
}
示例4: getCloudSolrClient
import org.apache.solr.client.solrj.impl.CloudSolrClient; //导入方法依赖的package包/类
private SolrClient getCloudSolrClient() {
LOG.debug("Creating CloudSolrClient using ZooKeeper: '{}'", solrZKHost);
CloudSolrClient client = new CloudSolrClient(solrZKHost);
client.setParser(new XMLResponseParser());
return client;
}