SolrJ : Server refused connection

余生长醉 提交于 2021-02-11 13:09:40

问题


For a customer, I need to write a search engine running on Linux. I am using SolrJ and did not configure anything else so far.

I followed https://lucene.apache.org/solr/guide/7_4/using-solrj.html#common-build-systems and thus added SolrJ in the project pom.xml, and also that tutorial.

The SolR client is instanciated like :

solrClient = new HttpSolrClient.Builder(
                GeneralSettings.getRootSolrPath() + "/" + getCollectionName()).
                build();

But for any query or commit I keep getting org.apache.solr.client.solrj.SolrServerException: Server refused connection at: http://localhost:8983/solr/test. I read http://lucene.472066.n3.nabble.com/Default-query-error-quot-Server-refused-connection-quot-td4010806.html but I am already using the expected port.

My understanding of the java doc SolrClient ’s handle the work of connecting to and communicating with Solr, and are where most of the user configuration happens. is that I only need to import the jar and then everything will work out of the box.

But as I keep getting this "Server refused connection" error I may have to configure something, but I could not find how to configure SolrJ (use solrconfig.xml or core.properties or call System.setProperty or call an API).

Please note that Apache may be running somewhere because I used to test some sites on it.

So how to get rid of this "Server refused connection" error?

Any help or tutorial to set SolrJ up based on Solr available doc would be very much appreciated,

Edit 2018-08-12 16:10

I thought SolrJ could work like Lucene, without a server, but it looks that I missed one essential piece: installing Solr (see https://www.baeldung.com/apache-solrj). I'll give it a try and post updates.


回答1:


In case it might help someone else starting with SolrJ here are the steps I did to get rid of the error mentionned in the title (actually I followed https://www.baeldung.com/apache-solrj).

  1. Downloaded the latest binary release of Solr
  2. Extracted it somewhere
  3. CDed into that dir
  4. Lauched bin/solr start from that dir
  5. Created a core with bin/solr create -c coreName (maybe another way exists but I hadn't been able to make it work so far)

Then Solr was running and listening on port 8983, and my Java app could connect to it via SolrJ.



来源:https://stackoverflow.com/questions/51808251/solrj-server-refused-connection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!