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

Reply via email to