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 Archon810 <ar...@gmail.com> on 2009/08/15 00:18:45 UTC

Solr conditional adds/updates?

I have a fairly simple need to do a conditional update in Solr, which is
easily accomplished in MySQL.

For example,

    * I have 100 documents with a unique field called <id>
    * I am POSTing 10 documents, some of which may be duplicate <id>s, in
which case Solr would update the existing records with the same <id>s
    * I have a field called <dateCreated> and I would like to only update a
<doc> if the new <dateCreated> is greated than the old <dateCreated> (this
applies to duplicate <id>s only, of course)

How would I be able to accomplish such a thing?

The context is trying to combat race conditions resulting in multiple adds
for the same ID but executing in the wrong order.

Thanks.

-- 
View this message in context: http://www.nabble.com/Solr-conditional-adds-updates--tp24979499p24979499.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Solr conditional adds/updates?

Posted by Jason Rutherglen <ja...@gmail.com>.
>  It seems like this would require some sort of Java implementation?

Yes, custom Java code would need to be written and tested etc.

On Fri, Aug 14, 2009 at 3:35 PM, Archon810<ar...@gmail.com> wrote:
>
> It seems like this would require some sort of Java implementation?
> Unfortunately I'm not a Java developer but I am in charge of implementing
> Solr. Any more detailed/straightforward instructions are very much
> appreciated.
>
> Thank you.
>
>
> Jason Rutherglen-2 wrote:
>>
>> You could implement optimistic concurrency? Where a version is
>> stored in the document? Or using the date system you described.
>>
>> Override DirectUpdateHandler2.addDoc with the custom logic.
>>
>> It seems like we should have a way of performing this without
>> custom code and/or an easier way to plug logic into
>> UpdateHandler. Basic SQL like functions should be possible or
>> simply a Lucene query (which can with QP2.0 support SQL like
>> syntax).
>>
>> On Fri, Aug 14, 2009 at 3:18 PM, Archon810<ar...@gmail.com> wrote:
>>>
>>> I have a fairly simple need to do a conditional update in Solr, which is
>>> easily accomplished in MySQL.
>>>
>>> For example,
>>>
>>>    * I have 100 documents with a unique field called <id>
>>>    * I am POSTing 10 documents, some of which may be duplicate <id>s, in
>>> which case Solr would update the existing records with the same <id>s
>>>    * I have a field called <dateCreated> and I would like to only update
>>> a
>>> <doc> if the new <dateCreated> is greated than the old <dateCreated>
>>> (this
>>> applies to duplicate <id>s only, of course)
>>>
>>> How would I be able to accomplish such a thing?
>>>
>>> The context is trying to combat race conditions resulting in multiple
>>> adds
>>> for the same ID but executing in the wrong order.
>>>
>>> Thanks.
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Solr-conditional-adds-updates--tp24979499p24979499.html
>>> Sent from the Solr - User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Solr-conditional-adds-updates--tp24979499p24979676.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>

Re: Solr conditional adds/updates?

Posted by Archon810 <ar...@gmail.com>.
It seems like this would require some sort of Java implementation?
Unfortunately I'm not a Java developer but I am in charge of implementing
Solr. Any more detailed/straightforward instructions are very much
appreciated.

Thank you.


Jason Rutherglen-2 wrote:
> 
> You could implement optimistic concurrency? Where a version is
> stored in the document? Or using the date system you described.
> 
> Override DirectUpdateHandler2.addDoc with the custom logic.
> 
> It seems like we should have a way of performing this without
> custom code and/or an easier way to plug logic into
> UpdateHandler. Basic SQL like functions should be possible or
> simply a Lucene query (which can with QP2.0 support SQL like
> syntax).
> 
> On Fri, Aug 14, 2009 at 3:18 PM, Archon810<ar...@gmail.com> wrote:
>>
>> I have a fairly simple need to do a conditional update in Solr, which is
>> easily accomplished in MySQL.
>>
>> For example,
>>
>>    * I have 100 documents with a unique field called <id>
>>    * I am POSTing 10 documents, some of which may be duplicate <id>s, in
>> which case Solr would update the existing records with the same <id>s
>>    * I have a field called <dateCreated> and I would like to only update
>> a
>> <doc> if the new <dateCreated> is greated than the old <dateCreated>
>> (this
>> applies to duplicate <id>s only, of course)
>>
>> How would I be able to accomplish such a thing?
>>
>> The context is trying to combat race conditions resulting in multiple
>> adds
>> for the same ID but executing in the wrong order.
>>
>> Thanks.
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Solr-conditional-adds-updates--tp24979499p24979499.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Solr-conditional-adds-updates--tp24979499p24979676.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Solr conditional adds/updates?

Posted by Jason Rutherglen <ja...@gmail.com>.
You could implement optimistic concurrency? Where a version is
stored in the document? Or using the date system you described.

Override DirectUpdateHandler2.addDoc with the custom logic.

It seems like we should have a way of performing this without
custom code and/or an easier way to plug logic into
UpdateHandler. Basic SQL like functions should be possible or
simply a Lucene query (which can with QP2.0 support SQL like
syntax).

On Fri, Aug 14, 2009 at 3:18 PM, Archon810<ar...@gmail.com> wrote:
>
> I have a fairly simple need to do a conditional update in Solr, which is
> easily accomplished in MySQL.
>
> For example,
>
>    * I have 100 documents with a unique field called <id>
>    * I am POSTing 10 documents, some of which may be duplicate <id>s, in
> which case Solr would update the existing records with the same <id>s
>    * I have a field called <dateCreated> and I would like to only update a
> <doc> if the new <dateCreated> is greated than the old <dateCreated> (this
> applies to duplicate <id>s only, of course)
>
> How would I be able to accomplish such a thing?
>
> The context is trying to combat race conditions resulting in multiple adds
> for the same ID but executing in the wrong order.
>
> Thanks.
>
> --
> View this message in context: http://www.nabble.com/Solr-conditional-adds-updates--tp24979499p24979499.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>