Skip to main content
rrrajesh
Gold ⭐️⭐️
Gold ⭐️⭐️
Jan 4, 2018 3:25 AM UTC

How to delete Solr collections data beyond 7 days

  • Oct 5, 2026 8:46 AM UTC
  • 3 replies
  • 10439 views
  • Translate All

Command to delete a particular solr collection:-


Example:-

curl "http://<SOLR-HOSTNAME>:8886/solr/audit_logs/update?commit=true" -H "Content-Type: text/xml" --data-binary "<delete><query>evtTime:[* TO NOW-7DAYS]</query></delete>"

In this example,

audit_logs - is the collection name.
TO NOW-7DAYS - Will delete the data older than 7 days.

3 replies

guaishi_2001
Silver ⭐️⭐️
Jan 5, 2018 8:56 AM UTC

thanks a lot.

Translate
achandra
Silver ⭐️⭐️⭐️
Apr 27, 2018 6:11 PM UTC

I get the following error:

<?xml version="1.0" encoding="UTF-8"?> <response> <lst name="responseHeader"><int name="status">400</int><int name="QTime">1</int></lst><lst name="error"><lst name="metadata"><str name="error-class">org.apache.solr.common.SolrException</str><str name="root-error-class">org.apache.solr.parser.ParseException</str></lst><str name="msg">org.apache.solr.search.SyntaxError: Cannot parse 'evtTime:[* TO NOW- 7DAYS]': Encountered " <RANGE_GOOP> "7DAYS "" at line 1, column 19. Was expecting one of: "]" ... "}" ... </str><int name="code">400</int></lst>

Translate
smdas
Gold ⭐️⭐️
Gold ⭐️⭐️
Aug 4, 2022 9:28 AM UTC

Hello @achandra, This is an Old Post yet closing the same by sharing the feedback concerning your ask for wider audience. The API is failing owing to Space between "NOW-" & "7DAYS". There shouldn't be any gap between the same. 

 

In Summary, the Command is below, where Customer needs to set the HTTP(s) header, Solr Host & Solr Port accordingly. Additionally, the Example uses "ranger_audits" Collection & "evtTime" field to delete any Documents older than 7 Days:

### curl -k --negotiate -u : "http[s]://<Any Solr Host FQDN>:<Solr Port>/solr/ranger_audits/update?commit=true" -H "Content-Type: text/xml" --data-binary "<delete><query>evtTime:[* TO NOW-7DAYS]</query></delete>"

 

Regards, Smarak

Translate