mysql org.apache.solr.common.SolrException:文档缺少必需的uniqueKey字段:身份证

hec6srdp  于 2023-01-08  发布在  Mysql
关注(0)|答案(3)|浏览(134)

当使用Apache Solr索引MySQL数据库表时,我收到以下错误:

org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey field: id

这是什么意思,我该怎么修?
谢谢你。

uqzxnwby

uqzxnwby1#

这意味着Solr试图索引一个没有指定字段id的文档,在schema.xml中定义了一个uniqueKey字段,Solr索引的每个文档都需要这样一个id。

kgsdhlau

kgsdhlau2#

其中一个原因必须是在Solr中不应该有id字段作为整数。它应该总是字符串。我得到了同样的问题,因为我定义了id字段作为整数而不是字符串。

aurhwmvo

aurhwmvo3#

我遇到了同样的错误,我的表名是voter,我使用voterid as作为唯一ID,但是在我将列名voterid改为id之后,它对我起作用了。

<dataConfig>
  <dataSource type="JdbcDataSource"
            driver="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost/test"
            user="root"
            password="root" /> 
  <document name="voter">
    <entity name="voter" query="select *  from voter;" >
 <field column="id" name="id"/>    
   <field column="voter_name" name="voter_name"/> 
<field column="age" name="age"/>   
</entity>
  </document>
</dataConfig>

Schema.xml File(I added 2 field , id was already present in the file)

第一个月
<field name="age" type="int" indexed="true" stored="true"/>
<field name="id" type="string" indexed="true" stored="true"/>

相关问题