【发布时间】:2011-08-12 00:36:42
【问题描述】:
我正在使用 SolrNET 将文档发布到 Solr 索引,以及从索引中删除文档。
这一直有效到现在。
我所做的是这样的:
- 在 schema.config 中,添加了一个字符串字段(这个新字段存储了一个 GUID)而不是之前的 UUID 字段
- 重新启动 Tomcat
(我从 UUID 字段切换到字符串字段,因为它不适合我,但这是另一回事。)
这是我的 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="text" 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" />
此查询以前有效:
var q = solr.Query(Query.Field("id").Is(item.Id.ToString()) && Query.Field("searchobjecttype").Is(item.SearchObjectType));
solr.Delete(q);
solr.Commit();
虽然现在不行。
调试时,我可以看到查询匹配文档(当查询找到项目时,NumFound 属性返回大于 0)。但是什么都没有被删除。
当我尝试通过 Solr 的 Web 界面删除同一个文档时,它可以工作。
我错过了什么? :)
干杯,谢谢。
【问题讨论】:
-
为什么 UUID 字段不起作用?
-
它确实“有效”,但是,我无法从实时索引中删除文档 - 但它在我的本地计算机上有效。因此,我现在要测试我的解决方法.. 只是一个替代解决方案,看看问题是否可以解决:)