You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Vitaliy Avdeev <va...@sistyma.net> on 2010/08/06 17:00:51 UTC

Deleting old index data from solr. But HDD spaces doesn`t free.

Hello.
I am deliting old data from solr such way.

                String url = "http://192.168.5.138:8080/apache-solr-1.4.0/";
                CommonsHttpSolrServer server = new
CommonsHttpSolrServer(url);
                server.setDefaultMaxConnectionsPerHost(200);
                server.setAllowCompression(true);
                server.setMaxRetries(1);

                Calendar cal = Calendar.getInstance();
                cal.roll(Calendar.MONTH, false);
                SimpleDateFormat sdf = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
                String query = String.format("publishedDate:[* TO
%s]",sdf.format(cal.getTime()));
                System.out.println(query);
                server.deleteByQuery( query );
                server.commit();

Data disapears feom index but But HDD spaces doesn`t free.

What I am doing wrong?

Re: Deleting old index data from solr. But HDD spaces doesn`t free.

Posted by Jan Høydahl / Cominvent <ja...@cominvent.com>.
What you are missing is a final
server.optimize();

Deleting a document will only mark it as deleted in the index until an optimize. If disk space is a real problem in your case because you e.g. update all docs in the index frequently, you can trigger an optimize(), say nightly.

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com
Training in Europe - www.solrtraining.com

On 6. aug. 2010, at 17.00, Vitaliy Avdeev wrote:

> Hello.
> I am deliting old data from solr such way.
> 
>                String url = "http://192.168.5.138:8080/apache-solr-1.4.0/";
>                CommonsHttpSolrServer server = new
> CommonsHttpSolrServer(url);
>                server.setDefaultMaxConnectionsPerHost(200);
>                server.setAllowCompression(true);
>                server.setMaxRetries(1);
> 
>                Calendar cal = Calendar.getInstance();
>                cal.roll(Calendar.MONTH, false);
>                SimpleDateFormat sdf = new
> SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
>                String query = String.format("publishedDate:[* TO
> %s]",sdf.format(cal.getTime()));
>                System.out.println(query);
>                server.deleteByQuery( query );
>                server.commit();
> 
> Data disapears feom index but But HDD spaces doesn`t free.
> 
> What I am doing wrong?