1
我正在使用SolrNET來管理我的Solr索引。在使用名爲「guid」的新uniqueKey字段更新架構之後,我無法將文檔添加到Solr。無法添加到Solr索引 - 文檔缺少uniqueKey字段?
這是Tomcat的日誌錯誤:
org.apache.solr.common.SolrException: Document is missing uniqueKey field guid
我加入這樣一個對象到Solr:
return new T()
{
GUID = Guid.NewGuid().ToString(),
Id = reader.GetInt32(0),
Heading = reader.GetString(1),
Body = freeText,
ForumRoom = reader.GetInt32(3),
ForumTopicId = reader.GetInt32(9),
SearchObjectType = reader.GetBoolean(5) ? SearchBase.ObjectType.ForumReply.ToString() : SearchBase.ObjectType.ForumTopic.ToString(),
Date = reader.GetDateTime(6)
};
奇怪的,本地測試時,這個工作得很好,但是沒有按根本不工作。
這是schema.config的樣子:
<fields>
<field name="id" type="int" indexed="true" stored="true" required="true" />
<field name="searchobjecttype" type="string" indexed="true" stored="true" required="true" />
<field name="heading" type="text" indexed="true" stored="false" required="false" />
<field name="body" type="text" indexed="true" stored="false" required="false" />
<field name="locationid" type="int" indexed="true" stored="true" required="false" />
<field name="currentlocationid" type="int" indexed="true" stored="true" required="false" />
<field name="countryid" type="int" indexed="true" stored="true" required="false" />
<field name="currentcountryid" type="int" indexed="true" stored="true" required="false" />
<field name="forumroom" type="int" indexed="true" stored="true" required="false" />
<field name="forumtopicid" type="int" indexed="true" stored="true" required="false" />
<field name="dt" type="date" indexed="true" stored="false" required="false" />
<field name="txt" type="text" indexed="true" stored="true" multiValued="true" />
<field name="guid" type="string" indexed="true" stored="true" required="false" />
</fields>
<copyField source="id" dest="txt" />
<copyField source="searchobjecttype" dest="txt" />
<copyField source="heading" dest="txt" />
<copyField source="body" dest="txt" />
<copyField source="locationid" dest="txt" />
<copyField source="currentlocationid" dest="txt" />
<copyField source="countryid" dest="txt" />
<copyField source="currentcountryid" dest="txt" />
<copyField source="forumroom" dest="txt" />
<copyField source="forumtopicid" dest="txt" />
<copyField source="dt" dest="txt" />
<uniqueKey>guid</uniqueKey>
<defaultSearchField>txt</defaultSearchField>
<solrQueryParser defaultOperator="AND" />
我缺少什麼?