solrCloud源码分析之CloudSolrClient
程序员文章站
2022-03-23 13:46:43
...
CloudSolrClient是solrj提供的客户端与solrCloud交互的类。该类的实例与zookeeper进行通信来确定solrCloud collections中的solr endpoint,然后使用LBHttpSolrClient发送请求。
CloudSolrClient查询简单代码:
http://www.cnblogs.com/davidwang456/p/4971298.html
CloudSolrClient查询简单代码:
import java.io.IOException; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.impl.XMLResponseParser; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.SolrDocumentList; public class SolrJCloudClientSearch { public static void main(String[] args) throws SolrServerException, IOException { String zkHost = "127.0.0.1:9983"; CloudSolrClient server = new CloudSolrClient(zkHost); //server = new CloudSolrClient(zkHost); server.setParser(new XMLResponseParser()); SolrQuery parameters = new SolrQuery(); parameters.set("q", "*:*"); parameters.set("qt", "/select"); parameters.set("collection", "Test"); QueryResponse response = server.query(parameters); SolrDocumentList list = response.getResults(); System.out.println(list.size()); } }
http://www.cnblogs.com/davidwang456/p/4971298.html
上一篇: MySql 严格模式相关配置
下一篇: 查看Linux服务器CPU总核数