OK, you have two options:

1.1> do NOT construct IDs with the version. Have two separate fields, id (which 
is the <uniqueKey> in your schema and a _separate_ field called tracking (note, 
there’s already by default an _version_ field, with underscores, for optimistic 
locking, do not use that).

1.2> Index the new version of the doc with the exact same ID and a new version 
and a new “tracking” value

Solr will replace the old version with the new version based on the ID.

Second:
Before you re-add the doc, issue a delete-by-query that identifies the 
document, something like q=id:123*

_How_ you determine that there is a new version of the doc you need to index is 
outside of Solr, you have to do that yourself.

Best,
Erick

> On Nov 5, 2019, at 3:56 AM, Khare, Kushal (MIND) 
> <kushal.kh...@mind-infotech.com> wrote:
> 
> Well, I cannot still completely relate to the solutions by you guys, am 
> looking into it as how could I achieve that with my application. Thanks !
> One thing, that I want to know is how to avoid full re-indexing, that is, 
> what I need is I don’t want that Solr index all the data every time some docs 
> are added, instead I want it to update it, that is index only newly added 
> docs. I hope this is possible, but how ?
> Because, currently I am using SolrJ  and it re-index complete data each time.
> 
> -----Original Message-----
> From: Peter Lancaster [mailto:peter.lancas...@findmypast.com]
> Sent: 04 November 2019 21:35
> To: solr-user@lucene.apache.org
> Subject: RE: Delete documents from the Solr index using SolrJ
> 
> You can delete documents in SolrJ by using deleteByQuery. Using this you can 
> delete any number of documents from your index or all your documents 
> depending on the query you specify as the parameter. How you use it is down 
> to your application.
> 
> You haven't said if your application performs a full re-index, but if so you 
> might find it useful to index a version number for your data which you 
> increment each time you perform the full indexing. Then you can increment 
> version, re-index data, delete data for old version number.
> 
> 
> -----Original Message-----
> From: Khare, Kushal (MIND) [mailto:kushal.kh...@mind-infotech.com]
> Sent: 04 November 2019 15:03
> To: solr-user@lucene.apache.org
> Subject: [EXTERNAL] RE: Delete documents from the Solr index using SolrJ
> 
> Thanks!
> Actually am working on a Java web application using SolrJ for Solr search.
> The users would actually be uploading/editing/deleting the docs. What have 
> done is defined a location/directory where the docs would be stored and 
> passed that location for indexing.
> So, I am quite confused how to carry on with the solution that you proposed. 
> Please guide !
> 
> -----Original Message-----
> From: David Hastings [mailto:hastings.recurs...@gmail.com]
> Sent: 04 November 2019 20:10
> To: solr-user@lucene.apache.org
> Subject: Re: Delete documents from the Solr index using SolrJ
> 
> delete them by query would do the trick unless im missing something 
> significant in what youre trying to do here. you can just pass in an xml
> command:
> '<delete><query>".$kill_query."</query></delete>'
> 
> On Mon, Nov 4, 2019 at 9:37 AM Khare, Kushal (MIND) < 
> kushal.kh...@mind-infotech.com> wrote:
> 
>> In my case, id won't be same.
>> Suppose, I have a doc with id : 20
>> Now, it's newer version would be either 20.1 or 22 What in this case?
>> -----Original Message-----
>> From: David Hastings [mailto:hastings.recurs...@gmail.com]
>> Sent: 04 November 2019 20:04
>> To: solr-user@lucene.apache.org
>> Subject: Re: Delete documents from the Solr index using SolrJ
>> 
>> when you add a new document using the same "id" value as another it
>> just over writes it
>> 
>> On Mon, Nov 4, 2019 at 9:30 AM Khare, Kushal (MIND) <
>> kushal.kh...@mind-infotech.com> wrote:
>> 
>>> Could you please let me know how to achieve that ?
>>> 
>>> 
>>> -----Original Message-----
>>> From: Jörn Franke [mailto:jornfra...@gmail.com]
>>> Sent: 04 November 2019 19:59
>>> To: solr-user@lucene.apache.org
>>> Subject: Re: Delete documents from the Solr index using SolrJ
>>> 
>>> I don’t understand why it is not possible.
>>> 
>>> However why don’t you simply overwrite the existing document instead
>>> of
>>> add+delete
>>> 
>>>> Am 04.11.2019 um 15:12 schrieb Khare, Kushal (MIND) <
>>> kushal.kh...@mind-infotech.com>:
>>>> 
>>>> Hello mates!
>>>> I want to know how we can delete the documents from the Solr index .
>>> Suppose for my system, I have a document that has been indexed, now
>>> its newer version is into use, so I want to use the latest one, for
>>> that I want the previous one to be deleted from the index.
>>>> Kindly help me a way out !
>>>> I went through many articles and blogs, got the way (methods) for
>>> deleting , but not actually, how to do it, because it's not possible
>>> to delete every time by passing id's in around 50,000 doc system.
>>>> Please suggest!
>>>> 
>>>> ________________________________
>>>> 
>>>> The information contained in this electronic message and any
>>>> attachments
>>> to this message are intended for the exclusive use of the
>>> addressee(s) and may contain proprietary, confidential or privileged 
>>> information.
>>> If you are not the intended recipient, you should not disseminate,
>>> distribute or copy this e-mail. Please notify the sender immediately
>>> and destroy all copies of this message and any attachments. WARNING:
>>> Computer viruses can be transmitted via email. The recipient should
>>> check this email and any attachments for the presence of viruses.
>>> The company accepts no liability for any damage caused by any
>>> virus/trojan/worms/malicious code transmitted by this email.
>>> www.motherson.com
>>> 
>>> ________________________________
>>> 
>>> The information contained in this electronic message and any
>>> attachments to this message are intended for the exclusive use of
>>> the
>>> addressee(s) and may contain proprietary, confidential or privileged
>>> information. If you are not the intended recipient, you should not
>>> disseminate, distribute or copy this e-mail. Please notify the
>>> sender immediately and destroy all copies of this message and any
>>> attachments. WARNING: Computer viruses can be transmitted via email.
>>> The recipient should check this email and any attachments for the
>>> presence of viruses. The company accepts no liability for any damage
>>> caused by any virus/trojan/worms/malicious code transmitted by this
>>> email. www.motherson.com
>>> 
>> 
>> ________________________________
>> 
>> The information contained in this electronic message and any
>> attachments to this message are intended for the exclusive use of the
>> addressee(s) and may contain proprietary, confidential or privileged
>> information. If you are not the intended recipient, you should not
>> disseminate, distribute or copy this e-mail. Please notify the sender
>> immediately and destroy all copies of this message and any
>> attachments. WARNING: Computer viruses can be transmitted via email.
>> The recipient should check this email and any attachments for the
>> presence of viruses. The company accepts no liability for any damage
>> caused by any virus/trojan/worms/malicious code transmitted by this
>> email. www.motherson.com
>> 
> 
> ________________________________
> 
> The information contained in this electronic message and any attachments to 
> this message are intended for the exclusive use of the addressee(s) and may 
> contain proprietary, confidential or privileged information. If you are not 
> the intended recipient, you should not disseminate, distribute or copy this 
> e-mail. Please notify the sender immediately and destroy all copies of this 
> message and any attachments. WARNING: Computer viruses can be transmitted via 
> email. The recipient should check this email and any attachments for the 
> presence of viruses. The company accepts no liability for any damage caused 
> by any virus/trojan/worms/malicious code transmitted by this email. 
> www.motherson.com ________________________________
> 
> This message is confidential and may contain privileged information. You 
> should not disclose its contents to any other person. If you are not the 
> intended recipient, please notify the sender named above immediately. It is 
> expressly declared that this e-mail does not constitute nor form part of a 
> contract or unilateral obligation. Opinions, conclusions and other 
> information in this message that do not relate to the official business of 
> findmypast shall be understood as neither given nor endorsed by it.
> ________________________________
> 
> ________________________________
> 
> The information contained in this electronic message and any attachments to 
> this message are intended for the exclusive use of the addressee(s) and may 
> contain proprietary, confidential or privileged information. If you are not 
> the intended recipient, you should not disseminate, distribute or copy this 
> e-mail. Please notify the sender immediately and destroy all copies of this 
> message and any attachments. WARNING: Computer viruses can be transmitted via 
> email. The recipient should check this email and any attachments for the 
> presence of viruses. The company accepts no liability for any damage caused 
> by any virus/trojan/worms/malicious code transmitted by this email. 
> www.motherson.com

Reply via email to