As we all know solr 4.0 supports atomic updates. http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22field.22 Is this supported in solrnet yet? If yes can I know the syntax. Thanks a ton.
-
1Just created an new task about this: http://code.google.com/p/solrnet/issues/detail?id=199 – Mauricio Scheffer Nov 13 '12 at 13:06
-
1Just as a workaround we can use the steps given in this blog http://teach-algo.blogspot.in/2013/03/atomic-updates-via-solrnet.html – Kaarthik Jun 18 '13 at 06:24
3 Answers
Thanks to the link you provided, do the following (with obvious changes to match your requirements and assuming you're using some DI container so that your ISolrOperations and ISolrConnection are taken care of via registration of SolrFacility):
private readonly ISolrOperations<Document> _solr;
private readonly ISolrConnection _solrConnection;
public SolrRecordRepository(ISolrOperations<Document> solr, ISolrConnection solrConnection)
{
_solr = solr;
_solrConnection = solrConnection;
}
...
public void UpdateField(int id, string fieldName, int value, bool optimize = false)
{
var updateXml = string.Format("<add><doc><field name='id'>{0}</field><field name='{1}' update='set'>{2}</field></doc></add>", id, fieldName, value);
_solrConnection.Post("/update", updateXml);
_solr.Commit();
if (optimize)
_solr.Optimize();
}

- 7,122
- 9
- 50
- 76
To the best of my knowledge, SolrNet does not yet support atomic updates and I do not see it listed on the SolrNet Project Issues List or any mention in the SolrNet Commits on GitHub.

- 22,415
- 3
- 57
- 68
Please note that the atomic updates are quite limited. If you expect an update feature a-la database - it's not yet there. Under the hood the document is recreated using the stored fields. it can be convenient when you don't want to resend all fields and don't care to store all the fields in the index. As far as I know, the 'real' update is about to come soon.

- 761
- 3
- 7