首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >org.apache.solr.common.SolrException:文档缺少必需的uniqueKey字段: id

问org.apache.solr.common.SolrException:文档缺少必需的uniqueKey字段: id
EN

Stack Overflow用户
提问于 2013-06-20 22:56:05
回答 3查看 8K关注 0票数 2

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

代码语言:javascript
复制
org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey field: id

这是什么意思?我怎么才能修复它?

谢谢。

EN

回答 3

Stack Overflow用户

发布于 2013-06-20 23:26:48

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

票数 0
EN

Stack Overflow用户

发布于 2015-03-20 04:35:50

我也犯了同样的错误。我的表名是voter,我使用voterid作为唯一的id。但是在我将列名voterid改为id之后,它对我起作用了。这是我的data-config.xml

代码语言:javascript
复制
<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="voter_name" type="string" indexed="true" stored="true"/>

<field name="age" type="int" indexed="true" stored="true"/>

<field name="id" type="string" indexed="true" stored="true"/>

票数 0
EN

Stack Overflow用户

发布于 2014-05-05 18:47:26

其中一个原因一定是在Solr中,不应该将id字段设置为int。它应该始终是字符串。我也遇到了同样的问题,因为我将id字段定义为整型而不是字符串。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17216994

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档