Community Articles

Find and share helpful community-sourced technical articles.
Labels (1)
avatar
Expert Contributor

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.
7,555 Views
0 Kudos
Comments
avatar
New Contributor

thanks a lot.

avatar
Explorer

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>

avatar
Super Collaborator

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