lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexandre Rafalovitch <arafa...@gmail.com>
Subject RE: suggestion for new custom atomic update
Date Sun, 26 Oct 2014 12:11:19 GMT
Can't you do the calculation in custom UpdateRequestProcessor?

Regards,
    Alex
On 26/10/2014 4:17 am, "Elran Dvir" <elrand@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.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message