Maxim Terletsky
Maxim Terletsky

Reputation: 113

Lucene check index size

Is there any way to check Lucene index size in the Lucene API? I mean other than going to FSDirectory.getDirectory and "manually" checking file size for every file in the directory? Thanks!

Maxim

Upvotes: 2

Views: 980

Answers (2)

Antonio Bakula
Antonio Bakula

Reputation: 20693

AFAIK there is no method to get index size, but instead of getting all files in directory you should grab file list with IndexReader :

    IndexReader ir = IndexReader.Open(FDirectory);
    foreach(string fName in ir.Directory().List())
    {
      // sum file sizes here
    }
    ir.Close();

Upvotes: 2

Maxim Terletsky
Maxim Terletsky

Reputation: 113

Well, I used var size = (from strFile in dir.ListAll() select dir.FileLength(strFile)).Sum();

where dir is Lucene.Net.Store.Directory where the index was created.. Seems good enough..

Maxim

Upvotes: 0

Related Questions