I’m using SolrNET to post documents to the Solr index, as well as remove documents from the index.
This has been working until now.
What I’ve done is this:
- In schema.config, added a string field (this new field stores a GUID) instead of the earlier UUID field
- Restarted Tomcat
(I switched from the UUID field to string field because it didn’t work well for me, but that’s another story.)
Here is what my schema.config looks like:
<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" />
This query worked before:
var q = solr.Query(Query.Field("id").Is(item.Id.ToString()) && Query.Field("searchobjecttype").Is(item.SearchObjectType));
solr.Delete(q);
solr.Commit();
While it won’t work now.
When debugging, I can see that the query matches documents (the NumFound property returns more than 0 when the query finds items). However nothing is deleted.
When I try to delete the same document through Solr’s web interface, it works.
What am I missing? 🙂
Cheers and thanks.
Try changing the guid field to
stringtype (you’ll have to reindex). Thetextfield type probably does some analysis and you don’t want to analyze this kind of data, you want to index it verbatim.