solrj 7.x Expected mime type application/octet-stream but got text/html.
出现这种情况是因为baseurl填写错误,最开始的时候我写的是用tomcat启动后浏览器中访问solr的地址
结果就出现了如题的异常,当然提示的是404,还有可能提示405,Method not allowed,method post is not supported等等
查看源码后发现给出的实例是这种格式http://ip:port/solr/+core,修改后重新测试正常
1 @Test
2 public void saveOrUpdate() throws Exception{
3 //url应为http://ip:port/solr/+core
4 HttpSolrClient solrClient = new HttpSolrClient.Builder("http://127.0.0.1:8080/solr/solrcore1").build();
5 SolrInputDocument document = new SolrInputDocument();
6 document.addField("id","test001");
7 document.addField("name_ik","my first solr client");
8 solrClient.add(document);
9 solrClient.commit();
10 }