views:

119

answers:

1

I am using SolrNet to intreract with a Solr index. I have a daemon application writing to the Solr index with adds/updates/deletes. However with SolrNet an Add with the same unique-key over-writes (replaces) the existing document, instead of appending (combining) them.

In Lucene I could do something like this where term is the Lucene term for the document key. How can I do this in SolrNet? I know of the (painful) way of appending field-by-field in a method, but surely there has to be a simpler way...

//where term is a Lucene term for the document key
                       if (objFacetsSearcher.DocFreq(term) > 0)
                        {
                            objWriter.UpdateDocument(term, doc);
                            updated++;
                        }
                        else
                        {
                            objWriter.AddDocument(doc);
                            added++;
                         }
A: 

As far as I know, this isn't supported in Solr yet. See SOLR-139.

Karl Johansson
Essentially the only way is to read the document back, append stuff and write back? That seems a of I/O - injurious to health. What approaches do you take to get around this?
Mikos
I was thinking of using Lucene to write to the Solr index directly. Any drawbacks to be aware of?
Mikos
@mikOS depending on environmental constraints, the most obvious way would be to read the entire document from the source system again. If that is not a viable option, then consider either implementing caching functionality in your connector (or as part of your document processing), or make input fields stored in your index, and read the document from Solr to populate any fields outside the delta.
Karl Johansson
@Karl, thanks much. What do you think of writing directly to the index using Lucene? Any potential issues to be aware of?
Mikos