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 "chadsteele.com" <ch...@chadsteele.com> on 2011/11/29 01:25:10 UTC

Re: conditionally update document on unique id

I wanted something similar for a file crawler/uploader in c#, but don't even
want to upload the document if it exists... I'm currently querying solr
first... Is this is optimal, silly, or otherwise? 

 var url = "http://solr/select?&q=myid.doc&rows=0";
 var txt = webclient.DownloadString(url);

if (txt.Contains("numFound=\"0\"")) 
{
    //upload the file
}

--
View this message in context: http://lucene.472066.n3.nabble.com/conditionally-update-document-on-unique-id-tp3119302p3543866.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: conditionally update document on unique id

Posted by Erick Erickson <er...@gmail.com>.
Note that the original question was when working from a custom update request
handler, you're not doing that at all...

It's not clear to me whether doing queries ahead of time like you're doing is
more or less speedy than a custom update request handler given that in
the one case you're querying a bunch, and in the other you're transmitting
data across the wire then throwing lots of it away. I guess it depends on
whether the file is sent across before deciding whether to add it or not in
a custom update processor. (hint, hint, someone who knows can
answer here <G>). It seems like it would have to be in order to get the
document ID out of the doc in the first place, at least in the XML case....

Anyway, your query could probably be made more efficient just from the
perspective of fewer search requests if you asked
for a bunch of IDs at once, something like:

http://solr/select?&q=id:(myid.doc1 OR myid.doc2 OR myid.doc3)&rows=3&fl=id

and you'd have to look inside the results for IDs if the result count > 0,
but I don't know whether it's enough faster to matter.

Best
Erick

On Mon, Nov 28, 2011 at 7:26 PM, chadsteele.com <ch...@chadsteele.com> wrote:
> oops... the query looks more like this
>
> http://solr/select?&q=*id:*myid.doc&rows=0
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/conditionally-update-document-on-unique-id-tp3119302p3543871.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: conditionally update document on unique id

Posted by "chadsteele.com" <ch...@chadsteele.com>.
oops... the query looks more like this

http://solr/select?&q=*id:*myid.doc&rows=0

--
View this message in context: http://lucene.472066.n3.nabble.com/conditionally-update-document-on-unique-id-tp3119302p3543871.html
Sent from the Solr - User mailing list archive at Nabble.com.