Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!
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.
10,442 Views
0 Kudos
Comments
avatar
New Member

thanks a lot.

avatar
New Member

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

Version history
Last update:
‎01-03-2018 07:25 PM
Updated by:
Contributors