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 Saumitra Srivastav <sa...@gmail.com> on 2014/05/22 17:13:28 UTC

Atomic update by query instead of ID

Is is possible to update a single field in multiple documents through atomic
updates, using a query instead of ID?

Here's my use case:

I have a multivalued field called 'tags' and a text field called 'content'.
User can define a pattern(regex) and name it, say my_pattern. Value
'my_pattern' should be added in 'tags' field in all the documents which have
that pattern in 'content' field.

Only way to do this is to get 'ID's of all the matched docs and send
individual atomic updates like mentioned in 
https://wiki.apache.org/solr/Atomic_Updates
<https://wiki.apache.org/solr/Atomic_Updates>  

But this will not scale when we have lots of matching documents. So is there
a way to specify a *query* for atomic updates, something like:

curl http://localhost:8983/solr/update -H 'Content-type:application/json' -d
'
[{
  "query"  : "content:pattern",
  "tags"    : {"add":"my_pattern"}
 }]'

I am using Solr 4.8.1 in cloud mode.



Regards,
Saumitra




--
View this message in context: http://lucene.472066.n3.nabble.com/Atomic-update-by-query-instead-of-ID-tp4137668.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Atomic update by query instead of ID

Posted by Jack Krupansky <ja...@basetechnology.com>.
No, but it sure would be nice to have the Elasticsearch feature of supplying 
a script for update.

-- Jack Krupansky

-----Original Message----- 
From: Saumitra Srivastav
Sent: Thursday, May 22, 2014 11:13 AM
To: solr-user@lucene.apache.org
Subject: Atomic update by query instead of ID

Is is possible to update a single field in multiple documents through atomic
updates, using a query instead of ID?

Here's my use case:

I have a multivalued field called 'tags' and a text field called 'content'.
User can define a pattern(regex) and name it, say my_pattern. Value
'my_pattern' should be added in 'tags' field in all the documents which have
that pattern in 'content' field.

Only way to do this is to get 'ID's of all the matched docs and send
individual atomic updates like mentioned in
https://wiki.apache.org/solr/Atomic_Updates
<https://wiki.apache.org/solr/Atomic_Updates>

But this will not scale when we have lots of matching documents. So is there
a way to specify a *query* for atomic updates, something like:

curl http://localhost:8983/solr/update -H 'Content-type:application/json' -d
'
[{
  "query"  : "content:pattern",
  "tags"    : {"add":"my_pattern"}
}]'

I am using Solr 4.8.1 in cloud mode.



Regards,
Saumitra




--
View this message in context: 
http://lucene.472066.n3.nabble.com/Atomic-update-by-query-instead-of-ID-tp4137668.html
Sent from the Solr - User mailing list archive at Nabble.com.