Delete from Solr index...

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Delete from Solr index...

escher2k
I am trying to remove documents from my index using "delete by query". However when I did this, the deleted
items seem to remain. This is the format of the XML file I am using -

<delete><query>load_id:20070424150841</query></delete>
<delete><query>load_id:20070425145301</query></delete>
<delete><query>load_id:20070426145301</query></delete>
<delete><query>load_id:20070427145302</query></delete>
<delete><query>load_id:20070428145301</query></delete>
<delete><query>load_id:20070429145301</query></delete>

When I do the deletes individually, it seems to work (i.e. create each of the above in a separate file). Does this
mean that each delete query request has to be executed separately ?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

Ryan McKinley
escher2k wrote:

> I am trying to remove documents from my index using "delete by query".
> However when I did this, the deleted
> items seem to remain. This is the format of the XML file I am using -
>
> <delete><query>load_id:20070424150841</query></delete>
> <delete><query>load_id:20070425145301</query></delete>
> <delete><query>load_id:20070426145301</query></delete>
> <delete><query>load_id:20070427145302</query></delete>
> <delete><query>load_id:20070428145301</query></delete>
> <delete><query>load_id:20070429145301</query></delete>
>
> When I do the deletes individually, it seems to work (i.e. create each of
> the above in a separate file). Does this
> mean that each delete query request has to be executed separately ?
>

correct, delete (unlike <add>) only accepts one command.

Just to note, if "load_id" is your unique key, you could also use:
  <delete><id>20070424150841</id></delete>

This will give you better performance and does not commit the changes
until you explicitly send <commit/>
Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

escher2k
Thanks Ryan. I need to use query since I am deleting a range of documents. From your
comment, I wasn't sure if one doesn't need to do an explicit commit when using delete by query.
Does delete by query not need an explicit commit.

Thanks.

ryan mckinley wrote
escher2k wrote:
> I am trying to remove documents from my index using "delete by query".
> However when I did this, the deleted
> items seem to remain. This is the format of the XML file I am using -
>
> <delete><query>load_id:20070424150841</query></delete>
> <delete><query>load_id:20070425145301</query></delete>
> <delete><query>load_id:20070426145301</query></delete>
> <delete><query>load_id:20070427145302</query></delete>
> <delete><query>load_id:20070428145301</query></delete>
> <delete><query>load_id:20070429145301</query></delete>
>
> When I do the deletes individually, it seems to work (i.e. create each of
> the above in a separate file). Does this
> mean that each delete query request has to be executed separately ?
>

correct, delete (unlike <add>) only accepts one command.

Just to note, if "load_id" is your unique key, you could also use:
  <delete><id>20070424150841</id></delete>

This will give you better performance and does not commit the changes
until you explicitly send <commit/>
Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

Ryan McKinley
escher2k wrote:
> Thanks Ryan. I need to use query since I am deleting a range of documents.
>>From your
> comment, I wasn't sure if one doesn't need to do an explicit commit when
> using delete by query.
> Does delete by query not need an explicit commit.
>

delete by query causes a commit *before* it executes...  I think you
still need one after.  From the javadoc:

http://svn.apache.org/repos/asf/lucene/solr/trunk/src/java/org/apache/solr/update/DirectUpdateHandler2.java

"deleteByQuery causes a commit to happen (close current index writer,
open new index reader) before it can be processed.  If deleteByQuery
functionality is needed, it's best if they can be batched and executed
together so they may share the same index reader."

I don't quite know what "batched" means since it only reads one command...


> Thanks.
>
>
> ryan mckinley wrote:
>> escher2k wrote:
>>> I am trying to remove documents from my index using "delete by query".
>>> However when I did this, the deleted
>>> items seem to remain. This is the format of the XML file I am using -
>>>
>>> <delete><query>load_id:20070424150841</query></delete>
>>> <delete><query>load_id:20070425145301</query></delete>
>>> <delete><query>load_id:20070426145301</query></delete>
>>> <delete><query>load_id:20070427145302</query></delete>
>>> <delete><query>load_id:20070428145301</query></delete>
>>> <delete><query>load_id:20070429145301</query></delete>
>>>
>>> When I do the deletes individually, it seems to work (i.e. create each of
>>> the above in a separate file). Does this
>>> mean that each delete query request has to be executed separately ?
>>>
>> correct, delete (unlike <add>) only accepts one command.
>>
>> Just to note, if "load_id" is your unique key, you could also use:
>>   <delete><id>20070424150841</id></delete>
>>
>> This will give you better performance and does not commit the changes
>> until you explicitly send <commit/>
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

Erik Hatcher
In reply to this post by Ryan McKinley
If you want to do this as a single delete-by-query, you could OR all  
the clauses together:

   <delete><query>load_id:(20070424150841 OR 20070425145301 .... )</
query></delete>

Erik


On May 1, 2007, at 2:14 AM, Ryan McKinley wrote:

> escher2k wrote:
>> I am trying to remove documents from my index using "delete by  
>> query".
>> However when I did this, the deleted
>> items seem to remain. This is the format of the XML file I am using -
>> <delete><query>load_id:20070424150841</query></delete>
>> <delete><query>load_id:20070425145301</query></delete>
>> <delete><query>load_id:20070426145301</query></delete>
>> <delete><query>load_id:20070427145302</query></delete>
>> <delete><query>load_id:20070428145301</query></delete>
>> <delete><query>load_id:20070429145301</query></delete>
>> When I do the deletes individually, it seems to work (i.e. create  
>> each of
>> the above in a separate file). Does this
>> mean that each delete query request has to be executed separately ?
>
> correct, delete (unlike <add>) only accepts one command.
>
> Just to note, if "load_id" is your unique key, you could also use:
>  <delete><id>20070424150841</id></delete>
>
> This will give you better performance and does not commit the  
> changes until you explicitly send <commit/>

Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

lupiss
In reply to this post by escher2k
Hola!
¿qué tal?

Tengo un problema parecido, necesito borrar algunos índices de mi solr, ya que los di de alta mientras hacía pruebas y ahora que entregaré el proyecto necesito que no aparezcan ya, se me complica esto ya que toda la información de solr está en inglés y pués yo no lo entiendo bien, en fin, espero me puedan ayudar ya que tengo solo unos días para entregar el proyecto, de antemano mil gracias! :)

Hello!
How are you?

I have a similar problem, I need to delete some of my SOLR indexes, since the various tests was as high and now that I need to deliver the project because they do not show, I compounded this, as all information is in English and SOLR after I do not understand, finally, I hope I can help because I have just days to deliver the project, a thousand thanks in advance! :)
Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

lupiss
hola de nuevo!
es cierto ese comando es el que borra un index, ya lo intenté y sí, así borraré mis registros de prueba de mi proyecto, estaría bien saber como borrarlo desde la aplicación mediante solrj, saludos, gracias :)

hello again!
this is true is the command that erases an index, and I tried and yes, that blot on my record of my test project, it would be nice to know how to delete it from your application using solrj, greetings, thank you:)
Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

Shalin Shekhar Mangar
On Thu, Apr 23, 2009 at 9:25 AM, lupiss <[hidden email]> wrote:

>
> hola de nuevo!
> es cierto ese comando es el que borra un index, ya lo intenté y sí, así
> borraré mis registros de prueba de mi proyecto, estaría bien saber como
> borrarlo desde la aplicación mediante solrj, saludos, gracias :)
>
> hello again!
> this is true is the command that erases an index, and I tried and yes, that
> blot on my record of my test project, it would be nice to know how to
> delete
> it from your application using solrj, greetings, thank you:)
>

You can use solrServer.deleteByQuery("*:*") and then call commit by
solrServer.commit(true, true);

This will erase the index.

--
Regards,
Shalin Shekhar Mangar.
Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

lupiss
You can use solrServer.deleteByQuery("*:*") and then call commit by
solrServer.commit(true, true);

This will erase the index.

--
Regards,
Shalin Shekhar Mangar.


hola gracias por contestar! ese comando ya lo había visto, pero borra todo los índices verdad?, yo quisiera borrar solo un índice de id = 2354345 por ejemplo, gracias

hello thank you for answering! that time it had already seen it, but erased all the indexes right?, I just delete an index id = 2354345 for example, thanks
Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

Shalin Shekhar Mangar
Try solrServer.deleteByQuery("id:2354345");

This will delete all documents which have id=2354345.

OR

solrServer.deleteById("2354345");

This works if id is uniqueKey in schema.xml
<uniqueKey>id</uniqueKey>

On Fri, Apr 24, 2009 at 10:43 PM, lupiss <[hidden email]> wrote:

>
> You can use solrServer.deleteByQuery("*:*") and then call commit by
> solrServer.commit(true, true);
>
> This will erase the index.
>
> --
> Regards,
> Shalin Shekhar Mangar.
>
>
> hola gracias por contestar! ese comando ya lo había visto, pero borra todo
> los índices verdad?, yo quisiera borrar solo un índice de id = 2354345 por
> ejemplo, gracias
>
> hello thank you for answering! that time it had already seen it, but erased
> all the indexes right?, I just delete an index id = 2354345 for example,
> thanks
> --
> View this message in context:
> http://www.nabble.com/Delete-from-Solr-index...-tp10264940p23221035.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>


--
Regards,
Shalin Shekhar Mangar.
Reply | Threaded
Open this post in threaded view
|

Re: Delete from Solr index...

vnchoudhary
In reply to this post by Ryan McKinley
I am looking for following solution in C#, Please provide sample code if possible:-

1. Delete all the index using delete query.
2. Take backup of all the old index, before regenerate.
3. Try to write unlike query for a field to delete stale index.
4. How can use transaction under index generation (delete all old index and generate index), so that if any error occurs than it will not affect old indexes.




ryantxu wrote
escher2k wrote:
> I am trying to remove documents from my index using "delete by query".
> However when I did this, the deleted
> items seem to remain. This is the format of the XML file I am using -
>
> <delete><query>load_id:20070424150841</query></delete>
> <delete><query>load_id:20070425145301</query></delete>
> <delete><query>load_id:20070426145301</query></delete>
> <delete><query>load_id:20070427145302</query></delete>
> <delete><query>load_id:20070428145301</query></delete>
> <delete><query>load_id:20070429145301</query></delete>
>
> When I do the deletes individually, it seems to work (i.e. create each of
> the above in a separate file). Does this
> mean that each delete query request has to be executed separately ?
>

correct, delete (unlike <add>) only accepts one command.

Just to note, if "load_id" is your unique key, you could also use:
  <delete><id>20070424150841</id></delete>

This will give you better performance and does not commit the changes
until you explicitly send <commit/>