I will explain with an example. Let's say field_a is sent in the update with the value of 5. field_a is already stored in the document with the value 8. After the update field_a should have the value 13 (sum). The value of field_b will be based on the value of 13 and not 5. Is there a way in URP to know what is the value which is already stored in field_a?
Thank you very much. -----Original Message----- From: Alexandre Rafalovitch [mailto:arafa...@gmail.com] Sent: Sunday, October 26, 2014 6:07 PM To: solr-user Subject: Re: suggestion for new custom atomic update I am not sure what the problem is. URP catches all operations. So, you can modify the source document to add the calculation when the field_a is either new or updated. Or are you trying to calculate things across multiple documents? In that case, neither mine nor your solution will work, I think. Regards, Alex. Personal: http://www.outerthoughts.com/ and @arafalov Solr resources and newsletter: http://www.solr-start.com/ and @solrstart Solr popularizers community: https://www.linkedin.com/groups?gid=6713853 On 26 October 2014 12:00, Elran Dvir <elr...@checkpoint.com> wrote: > Thanks for your response. > > If the calculation is based on the most recent summed value of field_a and > the value of field_a in the update, how can I? > > Thanks. > > -----Original Message----- > From: Alexandre Rafalovitch [mailto:arafa...@gmail.com] > Sent: Sunday, October 26, 2014 2:11 PM > To: solr-user > Subject: RE: suggestion for new custom atomic update > > Can't you do the calculation in custom UpdateRequestProcessor? > > Regards, > Alex > On 26/10/2014 4:17 am, "Elran Dvir" <elr...@checkpoint.com> wrote: > >> Hi all, >> >> Did anyone have a chance to review my idea? >> >> Thanks. >> >> -----Original Message----- >> From: Elran Dvir >> Sent: Monday, October 20, 2014 12:42 PM >> To: solr-user >> Subject: suggestion for new custom atomic update >> >> Hi all, >> >> This is my use case: >> I have a stored field, field_a, which is atomic updated (let's say by >> "inc"). field_a is stored but not indexed due to the large number of >> distinct values it can have. >> I need to index field_b (I need facet and stats on it) which is not >> in the document but its value is based on a calculation of the recent (e.g. >> summed) value of field_a. >> There is no way to do it nowadays. >> So I thought of a new method: custom atomic update. >> >> There will be a new interface in Solr: >> >> public interface CustomAtomicUpdater { >> public void update(SolrInputDocument oldDoc, String fieldName, >> Object >> fieldVal) ; } >> >> There will be a new attribute for fields in schema.xml called >> "customAtomicUpdateClass" (and all support in code, of course). >> The value is a class which is an implementation of CustomAtomicUpdater. >> In our example it will be defined for field_a. >> >> In method "getUpdatedDocument" in DistributedUpdateProcessor.java, we >> will add handling of "custom" case: >> >> } else if ("custom".equals(key)) { >> updateField = true; >> SchemaField sf = schema.getField(sif.getName()); >> String customAtomicUpdaterClassName = >> sf.getCustomAtomicUpdaterClass(); >> if (customAtomicUpdaterClassName == null) { >> throw new SolrException(ErrorCode.BAD_REQUEST, "There >> is no customAtomicUpdaterClass defined for " + sif + "."); >> } >> CustomAtomicUpdater updater = schema.getResourceLoader() >> .newInstance(customAtomicUpdaterClassName, >> CustomAtomicUpdater.class); >> if (updater == null) { >> throw new SolrException(ErrorCode.BAD_REQUEST, "Was >> unable to create instance of " + customAtomicUpdaterClassName + "."); >> } >> updater.update(oldDoc, sif.getName(), fieldVal); >> >> } >> >> In my implementation I will sum field_a (oldvalue + newvalue) and >> update field_b according to my logic. >> >> Example of use: >> <add> >> <doc> >> <field name="field_a" update="custom">128</field> >> </doc> >> </add> >> >> What do say about my suggestion? >> >> Thanks. >> > > > Email secured by Check Point Email secured by Check Point