Exception in thread "main" org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException:

Expected mime type application/octet-stream but got text/html.<html><head><title>Apache Tomcat/7.0.54 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /solr/core0/update/extract</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/solr/core0/update/extract</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.54</h3></body></html>

at org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:516)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206)
at solrj.CreateIndexFromPDF.indexFilesSolrCell(CreateIndexFromPDF.java:54)

at solrj.CreateIndexFromPDF.main(CreateIndexFromPDF.java:21)

部分代码:

        String urlString = "http://localhost:8080/solr/core0"; 
        SolrServer solr = new HttpSolrServer(urlString);  
        ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update/extract");  

是因为我用的: core0 (这个在当前的solr目录下是不存在的),已经被删除了。改为存在collection1  就正常通过。

所以有这样的错误一般是配置错误,或者操作的core核心不存在,或者没有配置对应的handler。都是路径错误,或者用法上的错误。

---------------------------------------

public class CreateIndexFromPDF {
public static void main(String[] args)  
    {  
        String fileName = "E:/apache-solr-ref-guide-4.4.pdf";   
        String solrId = "solr用户指南中文版.pdf";   
        try  
        {  
            indexFilesSolrCell(fileName, solrId);  
        }  
        catch (IOException e)  
        {  
            e.printStackTrace();  
        }  
        catch (SolrServerException e)  
        {  
            e.printStackTrace();  
        }  
          
    }  
      
    /** 从文件创建索引 
     * <功能详细描述> 
     * @param fileName 
     * @param solrId 
     * @see [类、类#方法、类#成员] 
     */  
    public static void indexFilesSolrCell(String fileName, String solrId)   
        throws IOException, SolrServerException  
    {  
        String urlString = "http://localhost:8080/solr/core0";  
        SolrServer solr = new HttpSolrServer(urlString);  
        ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update/extract");  
          
        String contentType="application/pdf";  
        up.addFile(new File(fileName), contentType);  
        up.setParam("literal.id", solrId);  
        up.setParam("uprefix", "attr_");  
        up.setParam("fmap.content", "attr_content");  
        up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);  
          
        solr.request(up);  
          
        QueryResponse rsp = solr.query(new SolrQuery("*:*"));  
        System.out.println(rsp);  
    }  
}

solr异常--Expected mime type application/octet-stream but got text/html.的更多相关文章

  1. solrj6.2异常--Expected mime type application/octet-stream but got text/html.

    org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://19 ...

  2. solrj 7.x Expected mime type application/octet-stream but got text/html.

    出现这种情况是因为baseurl填写错误,最开始的时候我写的是用tomcat启动后浏览器中访问solr的地址 结果就出现了如题的异常,当然提示的是404,还有可能提示405,Method not al ...

  3. Resource interpreted as Document but transferred with MIME type application/json laravel异常请求返回警告

    一般情况下,laravel在方法里可以向前端返回数组格式 return [], 框架可以自动将数组转成JSON字符串返回,但浏览器会报MIME类型警告, 如是做APP接口可以忽视该警告: 但在前端aj ...

  4. odoo 错误 Resource interpreted as Stylesheet but transferred with MIME type application/x-css:

    odoo8   页面内容显示一半,  web 控制台显示错误  Resource interpreted as Stylesheet but transferred with MIME type ap ...

  5. Django 导入css文件,样式不起作用。Resource interpreted as Stylesheet but transferred with MIME type application/x-css

    笔者今天在模板中加载css文件时,发现 css样式能够下载再来却无法起作用,而且,图片.js都能够正常使用. 并且 浏览器提示: Resource interpreted as Stylesheet ...

  6. 解决IE浏览器中出现“Resource interpreted as Document but transferred with MIME type application/json”问题

    在上传图片时,使用ajax提交,返回的数据格式为json.在测试时发现IE浏览器中,上传图片后,没有显示图片,而是弹出一个提示:是否保存UploadImg.json文件:而在其他浏览器中正常. 在Ch ...

  7. Invalid mime type "application nd.ms-excel; charset=utf-8;charset=utf-8": does not contain '/'

    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is ...

  8. Resource interpreted as Document but transferred with MIME type application/json

    转自:https://blog.csdn.net/just_lover/article/details/81207472 我在修改并保存后,界面返回提示“undifine”,实际我是看到有返回提示的. ...

  9. IE8 MIME type application/json not found

    如果: public ContentResult GetPaper(string testId) {     return ControllProctector.Do1(() =>        ...

随机推荐

  1. html语言中的meta元素

    1.定义语言  格式:〈meta http-equiv=″Content-Type″ content=″text/html; charset=gb2312″〉  这是META最常见的用法,在制作网页时 ...

  2. C#磁盘遍历——递归

    static void Main(string[] args) { //创建秒表,记录查询的总时间 Stopwatch timer = new Stopwatch(); timer.Start(); ...

  3. 百度,人人,新浪,腾讯等分享Js代码

    <!-- Baidu Button BEGIN -->                        <div id="bdshare" class=" ...

  4. Oralce9 的新方法: Merge into Using

    一.语义 MERGE语句是Oracle9i新增的语法,用来合并UPDATE和INSERT语句.通过MERGE语句,根据一张表或子查询的连接条件对另外一张表进行查询,连接条件匹配上的进行UPDATE,无 ...

  5. 第一章JSP基础语法

    jsp页面元素构成 jsp页面组成部分有:指令,注释,静态内容,表达式,小脚本,声明. jsp指令 page指令:通常位于jsp页面的顶端,同一个页面可以有多个page指令 include指令:将一个 ...

  6. ios&h5混合开发项目仿app页面跳转优化

    前言:本人原本是ios开发工程师,但由于现今H5的兴起,行内刮起了一阵混合开发的风气,趁着这股劲,我也学了前端开发,不说研究的多深,但也能胜任日常的开发工作.长话短说,现今的混合开发应该还处于摸索阶段 ...

  7. Ubuntu系列Crontab日记记录

    修改rsyslog文件,将/etc/rsyslog.d/50-default.conf 文件中的#cron.*前的#删掉 重启rsyslog服务service rsyslog restart 重启cr ...

  8. Python:文件操作

    #!/usr/bin/python3 str1 = input("请输入:") print("你输入的是:",str1) f=open("abc.tx ...

  9. gpload的简单实用

    准备工作: 1.因为gpload是对gpfdist的封装,因此使用gpload之前必须开启gpfdist的服务,不然无法使用. gpfdist -d /home/admin -p 8181 -l /t ...

  10. 关于A*寻路算法的认识

    最近要参加学校的APP比赛,我们组做的是一个3D迷宫的小APP,我负责的是迷宫的生成与寻路. 寻路算法选择的是A*寻路算法,具体参考的是下面的这篇博客. 本文主要是谈谈自己对A*算法的理解,具体细节, ...