在使用Apache Solr为MySQL数据库表建立索引时,我收到以下错误:
org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey field: id这是什么意思?我怎么才能修复它?
谢谢。
发布于 2013-06-20 23:26:48
这意味着Solr正在尝试索引一个没有指定字段id的文档。在您的schema.xml中定义了一个uniqueKey字段,由Solr索引的每个文档都需要这样一个id作为索引。
发布于 2015-03-20 04:35:50
我也犯了同样的错误。我的表名是voter,我使用voterid作为唯一的id。但是在我将列名voterid改为id之后,它对我起作用了。这是我的data-config.xml
<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"/>
发布于 2014-05-05 18:47:26
其中一个原因一定是在Solr中,不应该将id字段设置为int。它应该始终是字符串。我也遇到了同样的问题,因为我将id字段定义为整型而不是字符串。
https://stackoverflow.com/questions/17216994
复制相似问题