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 Bruno René Santos <br...@gmail.com> on 2013/08/08 10:58:41 UTC

JSON Update create different copies of the same document

Hello,

I thought that by adding a new document with the same id on Solr the
document already on Solr would be updated with the new info. But both
documents appear on the search results... How can I update a document?

Regards
Bruno Santos

-- 
Bruno René Santos
Lisboa - Portugal

Re: JSON Update create different copies of the same document

Posted by Jack Krupansky <ja...@basetechnology.com>.
You're getting yourself very, very confused. And then you're using the 
source code to confuse yourself even more! Sigh.

First, you wouldn't (shouldn't) use atomic update for "loading" batches of 
documents. Atomic update is for selectively update a subset of the fields of 
existing documents. If you want to update an entire document, just use 
normal update.

So called "versions" are an internal detail of SolrCloud, it's just a 
special field, _version_ - please ignore them, and please don't try to 
modify them or in any way depend on them. They are there, yes. Otherwise 
ignore them. Solr will take care of them.

Go back and take a look at the basic Solr tutorial, which has an example 
using JSON. Just follow that example. If you need to do more than that, ask 
simple questions before you go off with overly-complicated approaches (or 
reading source code) when simple approaches are usually all that are needed.

See:
http://lucene.apache.org/solr/4_4_0/tutorial.html

If you do in fact run into an actual problem, try to repro the problem using 
the standard Solr example shcema and config.

-- Jack Krupansky

-----Original Message----- 
From: Bruno René Santos
Sent: Friday, August 09, 2013 11:43 AM
To: solr-user@lucene.apache.org
Subject: Re: JSON Update create different copies of the same document

Hi,

I think I found out what is really happening. When I try to do a atomic
update the document id is transformed into a BytesRef (indexedId variable)
on the org.apache.solr.update.AddUpdateCommand. But on line 726 of
the org.apache.solr.update.processor.DistributedUpdateProcessor (
SolrInputDocument oldDoc =
RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id); ) the
oldDoc is null even for a document that i know it already exists on the
collection. Our Document ids are like PT_93369010_9999_4__2_en_PT
(strings). Also it seems that the processor only tries to find the first
match of the document, disregardinf its current latest version (unless the
document versions are laready sorted by their version?)... Anyone knows
what I am doing wrong? Or if this is a bug?

Regards
Bruno


On Fri, Aug 9, 2013 at 2:23 PM, Bruno René Santos 
<br...@gmail.com>wrote:

> Hi,
>
> I just saw overwrite option on the backoffice. I am loading the documents
> in 5000 document batches in JSON so I do not use this interface. How can I
> use this overwrite = true option in my environment? Or how solr admin
> interface translate this overwrite option into JSON  update syntax?
>
> Regards
> Bruno
>
>
> On Thu, Aug 8, 2013 at 3:22 PM, Jack Krupansky 
> <ja...@basetechnology.com>wrote:
>
>> Either your <uniqueKey> field values are in fact unique for those
>> separate documents, or your have overwrite="false" on the input 
>> documents.
>>
>> -- Jack Krupansky
>>
>> -----Original Message----- From: Bruno René Santos
>> Sent: Thursday, August 08, 2013 4:58 AM
>> To: solr-user@lucene.apache.org
>> Subject: JSON Update create different copies of the same document
>>
>>
>> Hello,
>>
>> I thought that by adding a new document with the same id on Solr the
>> document already on Solr would be updated with the new info. But both
>> documents appear on the search results... How can I update a document?
>>
>> Regards
>> Bruno Santos
>>
>> --
>> Bruno René Santos
>> Lisboa - Portugal
>>
>
>
>
> --
> Bruno René Santos
> Lisboa - Portugal
>



-- 
Bruno René Santos
Lisboa - Portugal 


Re: JSON Update create different copies of the same document

Posted by Bruno René Santos <br...@gmail.com>.
Hi,

I think I found out what is really happening. When I try to do a atomic
update the document id is transformed into a BytesRef (indexedId variable)
on the org.apache.solr.update.AddUpdateCommand. But on line 726 of
the org.apache.solr.update.processor.DistributedUpdateProcessor (
SolrInputDocument oldDoc =
RealTimeGetComponent.getInputDocument(cmd.getReq().getCore(), id); ) the
oldDoc is null even for a document that i know it already exists on the
collection. Our Document ids are like PT_93369010_9999_4__2_en_PT
(strings). Also it seems that the processor only tries to find the first
match of the document, disregardinf its current latest version (unless the
document versions are laready sorted by their version?)... Anyone knows
what I am doing wrong? Or if this is a bug?

Regards
Bruno


On Fri, Aug 9, 2013 at 2:23 PM, Bruno René Santos <br...@gmail.com>wrote:

> Hi,
>
> I just saw overwrite option on the backoffice. I am loading the documents
> in 5000 document batches in JSON so I do not use this interface. How can I
> use this overwrite = true option in my environment? Or how solr admin
> interface translate this overwrite option into JSON  update syntax?
>
> Regards
> Bruno
>
>
> On Thu, Aug 8, 2013 at 3:22 PM, Jack Krupansky <ja...@basetechnology.com>wrote:
>
>> Either your <uniqueKey> field values are in fact unique for those
>> separate documents, or your have overwrite="false" on the input documents.
>>
>> -- Jack Krupansky
>>
>> -----Original Message----- From: Bruno René Santos
>> Sent: Thursday, August 08, 2013 4:58 AM
>> To: solr-user@lucene.apache.org
>> Subject: JSON Update create different copies of the same document
>>
>>
>> Hello,
>>
>> I thought that by adding a new document with the same id on Solr the
>> document already on Solr would be updated with the new info. But both
>> documents appear on the search results... How can I update a document?
>>
>> Regards
>> Bruno Santos
>>
>> --
>> Bruno René Santos
>> Lisboa - Portugal
>>
>
>
>
> --
> Bruno René Santos
> Lisboa - Portugal
>



-- 
Bruno René Santos
Lisboa - Portugal

Re: JSON Update create different copies of the same document

Posted by Bruno René Santos <br...@gmail.com>.
Hi,

I just saw overwrite option on the backoffice. I am loading the documents
in 5000 document batches in JSON so I do not use this interface. How can I
use this overwrite = true option in my environment? Or how solr admin
interface translate this overwrite option into JSON  update syntax?

Regards
Bruno


On Thu, Aug 8, 2013 at 3:22 PM, Jack Krupansky <ja...@basetechnology.com>wrote:

> Either your <uniqueKey> field values are in fact unique for those separate
> documents, or your have overwrite="false" on the input documents.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Bruno René Santos
> Sent: Thursday, August 08, 2013 4:58 AM
> To: solr-user@lucene.apache.org
> Subject: JSON Update create different copies of the same document
>
>
> Hello,
>
> I thought that by adding a new document with the same id on Solr the
> document already on Solr would be updated with the new info. But both
> documents appear on the search results... How can I update a document?
>
> Regards
> Bruno Santos
>
> --
> Bruno René Santos
> Lisboa - Portugal
>



-- 
Bruno René Santos
Lisboa - Portugal

Re: JSON Update create different copies of the same document

Posted by Jack Krupansky <ja...@basetechnology.com>.
Either your <uniqueKey> field values are in fact unique for those separate 
documents, or your have overwrite="false" on the input documents.

-- Jack Krupansky

-----Original Message----- 
From: Bruno René Santos
Sent: Thursday, August 08, 2013 4:58 AM
To: solr-user@lucene.apache.org
Subject: JSON Update create different copies of the same document

Hello,

I thought that by adding a new document with the same id on Solr the
document already on Solr would be updated with the new info. But both
documents appear on the search results... How can I update a document?

Regards
Bruno Santos

-- 
Bruno René Santos
Lisboa - Portugal 


Re: JSON Update create different copies of the same document

Posted by Bruno René Santos <br...@gmail.com>.
Yes, id. I was just reading and maybe this happens because I do not send
the _version_ with the document? I tried to send it with a value chosen
(_versoin_=342342342) by me with Solr empty of documents and get the http
response 409 with the reason conflict.

Any ideas?

Regards
Bruno


On Thu, Aug 8, 2013 at 10:02 AM, Rafał Kuć <r....@solr.pl> wrote:

> Hello!
>
> Do you have the unique identifier specified in the schema.xml ?
>
> --
> Regards,
>  Rafał Kuć
>  Sematext :: http://sematext.com/ :: Solr - Lucene - ElasticSearch
>
> > Hello,
>
> > I thought that by adding a new document with the same id on Solr the
> > document already on Solr would be updated with the new info. But both
> > documents appear on the search results... How can I update a document?
>
> > Regards
> > Bruno Santos
>
>


-- 
Bruno René Santos
Lisboa - Portugal

Re: JSON Update create different copies of the same document

Posted by Rafał Kuć <r....@solr.pl>.
Hello!

Do you have the unique identifier specified in the schema.xml ?

-- 
Regards,
 Rafał Kuć
 Sematext :: http://sematext.com/ :: Solr - Lucene - ElasticSearch

> Hello,

> I thought that by adding a new document with the same id on Solr the
> document already on Solr would be updated with the new info. But both
> documents appear on the search results... How can I update a document?

> Regards
> Bruno Santos


Re: JSON Update create different copies of the same document

Posted by Yonik Seeley <yo...@lucidworks.com>.
On Thu, Aug 8, 2013 at 4:58 AM, Bruno René Santos <br...@gmail.com> wrote:
> I thought that by adding a new document with the same id on Solr the
> document already on Solr would be updated with the new info.

Yes, this should be the case.

> But both
> documents appear on the search results... How can I update a document?

Can you give an example to reproduce?

-Yonik
http://lucidworks.com