Reputation: 839
I want to update an existing record in Solr with a HttpWebRequest. I'm using Solr 4.3.0 and I don't want to use any libraries like SolrNet. What I want to do is prepare some data in Solr, and then perform a query against my application (that does use SolrNet) to test if the prepared data is returned when it is queried.
I'm having two problems.
Firstly, when performing an atomic update query, Solr complains that required fields are missing. I don't want to supply any fields except the uniqueID and the field being updated, is that possible?
Secondly, it seems that if I do supply all required fields, Solr creates a new document. This leads me to suspect that the uniquekey is not working as it should.
Unique key is:
<field name="ObjectGuid" type="string" indexed="true" stored="true" required="true" multiValued="false"/>
set like so:
<uniqueKey>ObjectGuid</uniqueKey>
I now have two documents in my Solr index, both with the same ObjectGuid...
Any help is appreciated.
Edit: Thank you for the replies so far.
1, 2 An example update document:
<add>
<doc>
<field name="ObjectGuid">33176f43-b446-481b-84e9-3facf4d71717</field>
<field name="MyDate" update="set">2013-07-14T08:25:09Z</field>
</doc>
</add>
3
Thank you for pointing out the Caveats. The fields in my schema all have stored="true"
except for the following two:
Furthermore, some <dynamicField>
nodes have stored="false"
Are these two cases possible causes for problems?
(Also, I can't find an occurrence of DistributedUpdateRequestProcessorFactory in solrconfig.xml. If I'm reading the Caveats correctly, if we haven't added any modifiers for that aspect, the behavior is default and shouldn't prevent atomic updates.)
Lastly I think there might be problems with case sensitivity in Guid fields.. I've noticed this before. We use a DataHandler to import data from a database, and the Guids are all uppercase in the Database. I've noticed (when using SolrNet) that the Guids are returned lowercase, but need to be supplied back to Solr uppercase... Has anyone else seen this behavior and if so, is there a way to avoid this?
Upvotes: 1
Views: 1341
Reputation: 839
The problem was related to upper/lowercase:
Solr does return the ObjectGuid in uppercase and expects it in uppercase. However, when using SolrNet or Guid.Parse in C#.Net, by default the Guid is transformed to lowercase.
If the lowercase Guid is then used, it doesn't match with the existing document in Solr, and a new record is created. Furthermore, because Solr is trying to create a new record, all required fields must be supplied, which explains both problems I was having.
Upvotes: 1