On 4/10/06, Chris Hostetter <[EMAIL PROTECTED]> wrote: > > : Is there any way to explicitly add a record using Solr, such that the > : add will fail if a record already exists with the same value in the > : unique ID field (as specified by the schema's uniqueKey field)? > > I was going to say <add allowDups="false" overwritePending="false" > overwriteCommitted="false"> should do what you want, > > > http://wiki.apache.org/solr/UpdateXmlMessages#head-3dfbf90fbc69f168ab6f3389daf68571ad614bef > > ...but that combination of options doesn't seem to be supported -- when i > tried to write a test case for it, it failed with this exception... > > SEVERE: org.apache.solr.core.SolrException: unsupported param > combo:add:,allowDups=false,overwritePending=false,overwriteCommitted=false > at > org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:197) > > ...i'm not sure how hard it would be to add that, the UpdateHandler is > already checking for the dumplicate, i'm not sure why it can't just throw > the new doc away when it finds one instead of deleting the old
It's not checking for a duplicate at the time the document is added to the index though... it removes duplicates later when the <commit/> command is given. That combination of parameters could be supported by DirectUpdateHander2 (the default) by doing a lookup in the index in addition to checking the local state (uncommitted documents). Feel free to file a JIRA bug, or, even better, provide a patch. -Yonik