Solr抛出rg.apache.solr.client.solrj.impl.HttpSolrServer $ RemoteSolrException:预期的mime类型为application/octet-stream,但获得了text/html [英] Solr throwing rg.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: Expected mime type application/octet-stream but got text/html

查看:158
本文介绍了Solr抛出rg.apache.solr.client.solrj.impl.HttpSolrServer $ RemoteSolrException:预期的mime类型为application/octet-stream,但获得了text/html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Solr + Spring Data Solr进行Solr索引.

I am using Solr + Spring Data Solr for Solr Indexing.

尝试保存solr文档时出现以下错误.

I am getting following error when I am trying save the solr document.

HTTP Status 500 - Request processing failed; nested exception is org.springframework.data.solr.UncategorizedSolrException: Expected mime type application/octet-stream but got text/html.

这是我的代码: 配置:

Here is my code: Config:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:solr="http://www.springframework.org/schema/data/solr"
    xsi:schemaLocation="http://www.springframework.org/schema/data/solr http://www.springframework.org/schema/data/solr/spring-solr.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <solr:repositories base-package="my.solr.repo"
        multicore-support="true" />
    <solr:solr-server id="solrServer" url="http://localhost:8983/solr" />


    <bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
        <constructor-arg index="0" ref="solrServer" />
    </bean>

</beans>


@Repository
public class SolrMyRepository extends
        SimpleSolrRepository<SolrmyModel, Serializable> {
    @Autowired
    public SolrMyRepository(final SolrTemplate solrTemplate) {
        super(solrTemplate);
    }

}




@SolrDocument(solrCoreName = "my")
public class SolrMyModel {

    @Id
    @Indexed
    private Long id;

    @Indexed
    private String myTitle;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getMyTitle() {
        return myTitle;
    }

    public void setMyTitle(String myTitle) {
        this.myTitle = myTitle;
    }

}




@Service
public class SolrMyService {

    @Autowired
    private SolrMyRepository solrMyRepository;

    public void test() {
        final SolrMyModel model = new SolrMyModel();
        model.setId((long) 1);
        model.setTitle("My title");
        System.out.println(model);
        solrMyRepository.save(model);
    }
}

我不确定我还缺少什么,但是不断出现此错误.

I am not sure what else I am missing but constantly I am getting this error.

解决方案:

由于没有通过运行以下命令来创建Solr内核,因此我克服了上述问题.

I got over the above problem as I have not create a solr core by running following command.

./solr create -c my

目前,它如何以编程方式创建核心?

As now its working, how can I created core programatically?

推荐答案

我克服了上述问题,因为我没有通过运行以下命令来创建solr内核.

I got over the above problem as I have not create a solr core by running following command.

./solr创建-c my

./solr create -c my

这篇关于Solr抛出rg.apache.solr.client.solrj.impl.HttpSolrServer $ RemoteSolrException:预期的mime类型为application/octet-stream,但获得了text/html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆