关于类似主题有几个问题,但他们的解决方案似乎不适合我的情况。
环境:Solr4.2.1,Tomcat 7
我正在尝试索引公共movielens 数据,并(与每个人一样)从“示例”核心开始。我从架构中删除了一些与我无关的字段,并将其他字段添加到索引 movielens 字段:
<field name="id" type="string" indexed="true" required="true" stored="true" multiValued="false" />
<!-- fields for u.data in the grouplens data -->
<field name="user_number" type="string" indexed="true" stored="true" multiValued="false" />
<field name="item_number" type="text_general" indexed="true" stored="true"/>
<field name="rating" type="int" indexed="true" stored="true" />
<field name="timestamp" type="date" indexed="true" stored="true"/>
<!-- end of fields for u.data in the grouplens data -->
<!-- fields for u.user in the grouplens data , userid is already specified above -->
<field name="age" type="int" indexed="true" stored="true" />
<field name="gender" type="text_general" indexed="true" stored="true"/>
<field name="occupation" type="text_general" indexed="true" stored="true"/>
<field name="zipcode" type="text_general" indexed="true" stored="true"/>
<!-- end of fields for u.user in the grouplens data -->
...
<uniqueKey>id</uniqueKey>
我在我的 Java 索引器中添加所有字段,包括生成的“id”字段,我还打印出我正在添加的每个字段,所以从下面的控制台输出中您可以看到我确实添加了“id”字段以及其他...但是,我收到以下错误:
May 5, 2013 9:43:06 AM org.apache.solr.client.solrj.impl.HttpClientUtil createClient
INFO: Creating new http client, config:maxConnections=128&maxConnectionsPerHost=32&followRedirects=false
indexUserData() started for file: u.user
indexUserData() processing line: 1|24|M|technician|85711
adding field: [user_number, 1]
adding field: [id, u_user_1]
adding field: [age, 24]
adding field: [gender, M]
adding field: [occupation, technician]
adding field: [zipcode, 85711]
Exception in thread "main" org.apache.solr.common.SolrException: Document is missing mandatory uniqueKey field: id
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:404)
知道我缺少什么吗?谢谢!码头