我正在为使用Solrj索引而苦苦挣扎。
我想使用SolrCloud,我将我的连接设置如下:
SolrClient client = new CloudSolrClient.Builder().withSolrUrl("http://localhost:8983/solr/collectioname").build();
我有这个错误。我在这里发帖前检查了evruwhere,但我无法解决它
Exception in thread "main" java.lang.RuntimeException: Couldn't initialize a HttpClusterStateProvider (is/are the Solr server(s), [http://localhost:8983/solr/collectioname], down?)
at org.apache.solr.client.solrj.impl.CloudSolrClient$Builder.build(CloudSolrClient.java:1496)
at indexsolr.<init>(indexsolr.java:29)
at LoadData.toIndex(LoadData.java:100)
at LoadData.loadDocuments(LoadData.java:72)
at IndexLaunch.main(IndexLaunch.java:12)
Caused by: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/collectioname: Expected mime type application/octet-stream but got text/html. <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /solr/collectioname/admin/collections. Reason:
<pre> Not Found</pre></p>
</body>
</html>
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:607)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:255)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:244)
at org.apache.solr.client.solrj.SolrClient.request(SolrClient.java:1219)
at org.apache.solr.client.solrj.impl.HttpClusterStateProvider.fetchLiveNodes(HttpClusterStateProvider.java:189)
at org.apache.solr.client.solrj.impl.HttpClusterStateProvider.<init>(HttpClusterStateProvider.java:64)
at org.apache.solr.client.solrj.impl.CloudSolrClient$Builder.build(CloudSolrClient.java:1494)
... 4 more
发布于 2018-03-20 05:59:12
正如在前面的回答中提到的,SolrJ使用的URL中没有集合名称(我应该更直接地指出):
final String solrUrl = "http://localhost:8983/solr";
return new HttpSolrClient.Builder(solrUrl)
.withConnectionTimeout(10000)
.withSocketTimeout(60000)
.build();https://stackoverflow.com/questions/49370872
复制相似问题