關於類似主題有幾個問題,但他們的解決方案似乎不符合我的情況。Solr失敗並顯示「丟失了所需的唯一密鑰ID」錯誤
ENV: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)
任何想法我錯過了什麼? 謝謝! 濱海
是的,我確實 - 對不起,我沒有將該部分包含到模式片段中。我會更新原來的問題。 – Marina 2013-05-05 15:10:37