2

I would like to delete the indexes between date range instead of deleting all the documents in SOLR Dashboard. I have tried with rel_date like <delete><query>rel_date:[2022-01-01T00:00:00Z TO 2022-07-29T00:00:00Z]</query></delete> but it is not working. Is it possible to delete the index between the date range?

Appreciated if anyone can help with this. Thanks in advance!!

3 Answers 3

1

To achieve your goal you can use the following:

POST: https:{SOLRENDPOINT}/solr/{corename}/update/json?commit=true

Headers: Authorization: Bearer {token}

In the request body, you would use the Solr delete command to specify the query for removing documents from the index. In this case, you can use a range query to specify the date range for deleting the documents.

Body

{
    "delete": {
        "query": {query for remove}  e.g. "rel_date:[2022-01-01T00:00:00Z TO 2022-07-29T00:00:00Z]"
    }
}

This query will remove all documents from the index that have a rel_date field within the specified date range.

Note that after sending the delete request, you will need to perform a commit operation to ensure that the index is updated. This can be done by adding the commit=true parameter to the request URL or by sending a separate commit request to Solr.

0

You can do it by using a Solr query like below.

http://localhost:8983/solr/my_core_name/update?commit=true&stream.body=<delete><query>date:[2000-01-01T00:00:00Z TO 2018-07-29T00:00:00Z]</query></delete>

Try this and this will work.

Use this thread for more details.

https://stackoverflow.com/questions/23228727/deleting-solr-documents-from-solr-admin

Hope this helps.

0

I try it and it works for me. Try it with replace __smallupdateddate_tdt field with your field and date value according to your need and leave the T part as it is.

Also, just double check the field name is rel_date in Solr data.

<delete><query>rel_date:[2022-01-01T00:00:01Z TO 2022-07-29T23:59:59Z]</query></delete>

enter image description here

Hope it helps!

6
  • Hi Sumit, Thanks for the input. I have tried and i am getting the below error Remote error message: undefined field: "__smallupdateddate_tdt". I want to try this in xdb indexes Commented Apr 12, 2023 at 14:08
  • I mean you need to replace that field with your field. I used __smallupdateddate_tdt just as an example. Commented Apr 12, 2023 at 14:16
  • 1
    I've updated the query with your field. Can you try this <delete><query>rel_date:[2022-01-01T00:00:01Z TO 2022-07-29T23:59:59Z]</query></delete> Commented Apr 12, 2023 at 14:21
  • @KanniyappanKrishnan - Is that resolved your issue? Commented Apr 12, 2023 at 17:50
  • Query is working but i don't see the records has deleted between the dates. Commented Apr 13, 2023 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.