You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Gili Nachum <gi...@gmail.com> on 2015/10/28 20:33:25 UTC

Conditional Add/Overwrite a document

Hi, Is there a conditional Add operation in Solr?

My documents have "my_int" field and when re-adding a document with the
same ID, I would to overwrite the existing doc only if the new doc my_int
value is higher than that of the existing doc.

As a naive solution, I could first read the existing doc to check if it
exist or what the my_int value is, but I rather avoid the round trip, since
I need to support a high index throughput.

I'm willing to write some Solr plugin code if that's a must. If I do that
which class should I extend/add? Would setting the my_int values as
docValues help to make them more easily available to the indexer?

Re: Conditional Add/Overwrite a document

Posted by Gili Nachum <gi...@gmail.com>.
Amazing. Thanks Brendan.

On Thu, Oct 29, 2015 at 12:31 AM, Brendan Humphreys <
brendan@canva.com.invalid> wrote:

> Hi Gili,
>
> It sounds like Solr's DocBasedVersionConstraintsProcessor is what you are
> looking for:
>
>
> https://cwiki.apache.org/confluence/display/solr/Updating+Parts+of+Documents#UpdatingPartsofDocuments-DocumentCentricVersioningConstraints
>
> Cheers,
> -Brendan
>
> On 29 October 2015 at 06:33, Gili Nachum <gi...@gmail.com> wrote:
>
> > Hi, Is there a conditional Add operation in Solr?
> >
> > My documents have "my_int" field and when re-adding a document with the
> > same ID, I would to overwrite the existing doc only if the new doc my_int
> > value is higher than that of the existing doc.
> >
> > As a naive solution, I could first read the existing doc to check if it
> > exist or what the my_int value is, but I rather avoid the round trip,
> since
> > I need to support a high index throughput.
> >
> > I'm willing to write some Solr plugin code if that's a must. If I do that
> > which class should I extend/add? Would setting the my_int values as
> > docValues help to make them more easily available to the indexer?
> >
>
> --
> [image: Canva] <https://canva.com>
> Empowering the world to design
> Also, we're hiring. Apply here! <https://canva.com/careers>
> [image: Twitter] <https://twitter.com/canva>[image: Facebook]
> <https://facebook.com/canva>[image: LinkedIn]
> <https://au.linkedin.com/company/canva>[image: Instagram]
> <https://instagram.com/canva>
>

Re: Conditional Add/Overwrite a document

Posted by Brendan Humphreys <br...@canva.com.INVALID>.
Hi Gili,

It sounds like Solr's DocBasedVersionConstraintsProcessor is what you are
looking for:

https://cwiki.apache.org/confluence/display/solr/Updating+Parts+of+Documents#UpdatingPartsofDocuments-DocumentCentricVersioningConstraints

Cheers,
-Brendan

On 29 October 2015 at 06:33, Gili Nachum <gi...@gmail.com> wrote:

> Hi, Is there a conditional Add operation in Solr?
>
> My documents have "my_int" field and when re-adding a document with the
> same ID, I would to overwrite the existing doc only if the new doc my_int
> value is higher than that of the existing doc.
>
> As a naive solution, I could first read the existing doc to check if it
> exist or what the my_int value is, but I rather avoid the round trip, since
> I need to support a high index throughput.
>
> I'm willing to write some Solr plugin code if that's a must. If I do that
> which class should I extend/add? Would setting the my_int values as
> docValues help to make them more easily available to the indexer?
>

-- 
[image: Canva] <https://canva.com>
Empowering the world to design
Also, we're hiring. Apply here! <https://canva.com/careers>
[image: Twitter] <https://twitter.com/canva>[image: Facebook] 
<https://facebook.com/canva>[image: LinkedIn] 
<https://au.linkedin.com/company/canva>[image: Instagram] 
<https://instagram.com/canva>