Atomic update with condition

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Atomic update with condition

SOLR4189
Hi all,

How can I change field value by specific condition in indexing?

Indexed Doc in SOLR: { id:1, foo:A }
Indexing Doc into SOLR: { id:1, foo: B }

foo is single value field.

Let's say I want to replace value of foo from A to B, if A > B, else do
nothing.

Thank you.




--
Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html
Reply | Threaded
Open this post in threaded view
|

Re: Atomic update with condition

Shawn Heisey-2
On 4/11/2018 10:52 AM, SOLR4189 wrote:
> How can I change field value by specific condition in indexing?
>
> Indexed Doc in SOLR: { id:1, foo:A }
> Indexing Doc into SOLR: { id:1, foo: B }
>
> foo is single value field.
>
> Let's say I want to replace value of foo from A to B, if A > B, else do
> nothing.

To the best of my knowledge, Solr can't do that without custom code.

You would need to have your indexing software ask Solr for the current
information and compare it to decide whether to send the indexing request.

The closest thing I can think of to this that Solr *does* do is the
increment capability in the Atomic Update feature.  And it's only
semi-related, not precisely what you're asking for.  I think that atomic
update is the only time that Solr looks at the existing record before
indexing a replacement.

https://lucene.apache.org/solr/guide/7_3/updating-parts-of-documents.html#atomic-updates

Thanks,
Shawn