Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete the documents a month ago

Tags:

solr

lucene

We are using Solr 1.4.

How to delete the documents a month ago?

like image 246
pengtaoli Avatar asked Dec 09 '11 06:12

pengtaoli


People also ask

How do I delete old documents?

Right-click your main hard drive (usually the C: drive) and select Properties. Click the Disk Cleanup button and you'll see a list of items that can be removed, including temporary files and more. For even more options, click Clean up system files. Tick the categories you want to remove, then click OK > Delete Files.

How do I permanently delete files from my documents?

Click Delete in the File Explorer Ribbon at the top of the window, or click the arrow underneath the Delete option and select Permanently delete. Clicking Delete sends the file to the Recycle Bin, while selecting the Permanently delete option deletes the file for good.

Why are my documents not deleting?

Close all programs In most cases, the reason you cannot delete a file is quite simple. The file or a file from the folder is still open or being used by another program.


2 Answers

We are doing something similar where we purge items from one of our indexes, using curl and taking advantage of the timestamp field in the Solr schema.

Here is the curl command that you would issue to delete items older than 30 days (using DateMathParser to calculate based on current day), using the timestamp field in the schema.

 curl "http://localhost:8983/solr/update?commit=true" -H "Content-Type: text/xml" 
   --data-binary "<delete><query>timestamp:[* TO NOW/DAY-30DAYS]</query></delete>"

Of course you will need to change the url to match your solr instance and you may choose to use a different field.

Also here is the field definition for the timestamp field from the schema.xml that comes with the Solr distribution in the example folder.

<field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
like image 167
Paige Cook Avatar answered Oct 04 '22 17:10

Paige Cook


You need to POST in order to do deletes but if you use the post.jar from the example folder in the installation it is simply:

java -Ddata=args -Dcommit=yes -jar post.jar "<delete><query>$DateField:[* TO $DateOneMonthAgo]</query></delete>"

where $DateField is the name of the field where the date is stored and $DateOneMonthAgo is the date one month from now (2011-11-09T11:48:00Z)

like image 32
lindstromhenrik Avatar answered Oct 04 '22 17:10

lindstromhenrik