我收到以下错误:
这是我的代码:
答案 0 :(得分:1)
乍一看,我看到一个问题:你永远不会告诉SolrServer
哪个核心或集合要解决。正如SolrJ docs中所述:
There are two ways to use an HttpSolrClient:
1) Pass a URL to the constructor that points directly at a particular core
SolrClient client = new HttpSolrClient("http://my-solr-server:8983/solr/core1");
In this case, you can query the given core directly, but you cannot query any other cores or issue CoreAdmin requests with this client.
2) Pass the base URL of the node to the constructor
SolrClient client = new HttpSolrClient("http://my-solr-server:8983/solr");
QueryResponse resp = client.query("core1", new SolrQuery("*:*"));
BTW:您应该使用您注释掉的Solrclient
对象。不推荐使用SolrServer
个对象。