尝试通过java连接到我的本地solr服务器5.4.0
public class Test {
public static void main(String[] args) throws SolrServerException, IOException{
// ArrayList<String> sellers = Util.readFile("sellersBP.csv", true);
SolrClient solr = new HttpSolrClient("http://localhost:8983/solr/#/techproducts/");
QueryResponse resp = solr.query("techproducts",new SolrQuery("*:*"));
}
}
但是,我收到一条错误消息,其中包含一堆 HTML 标记,并在其中显示。
Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at <a href="http://localhost:8983/solr/#/techproducts" rel="noreferrer noopener nofollow">http://localhost:8983/solr/#/techproducts</a>: Expected mime type application/octet-stream but got text/html.
<p>
No cores available
Go and create one
</p>
这很奇怪,因为我使用的是示例 solr 示例,它在我的 UI 中创建了一个名为 techproducts 的核心。有什么建议吗?
网址
最佳答案
URL http://localhost:8983/solr/#/techproducts/
具有本地 anchor (#
后面的所有内容),该 anchor 仅适用于浏览器本身(它永远不会发送到服务器)。管理 UI 中的 JavaScript 使用它来从正确的核心检索信息。
用于访问核心的实际 URL 为http://localhost:8983/solr/techproducts/
关于java - SOLR:没有可用的核心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34830860/