如何解决org.apache.solr.client.solrj.impl.HttpSolrServer $ RemoteSolrException

时间:2017-02-20 12:46:32

标签: solr solrj

我收到以下错误:

Following error is appear

这是我的代码:

Please format this as code

1 个答案:

答案 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个对象。