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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Vitaliy Avdeev
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?
Reply | Threaded
Open this post in threaded view
|

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

Jan Høydahl / Cominvent
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?