lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <ted.dunn...@gmail.com>
Subject Re: Are you able to list everything in index
Date Mon, 23 Mar 2009 23:01:46 GMT
This only mostly works.  You should also check for deleted documents or
verify that isn't an issue for you.  The document numbers in the range you
are looking at *are* guaranteed to correspond to a document that has been
added to the index, but if that document is deleted, then the number is not
re-used until you compress or optimize the index.  The results is that
MaxDoc may be larger than the number of documents in the index and your code
will throw an exception.

On Mon, Mar 23, 2009 at 3:48 PM, rockacola <rockacola@gmail.com> wrote:

>
> Hi Evert,
>
> Thanks for your tip, it actually gave me a hint toward my desired solution!
> This is what I've end up with:
>
>        public static List<Document> GetAll(string physicalIndexDirectory)
>        {
>            List<Document> list = new List<Document>();
>            IndexReader ir = IndexReader.Open(physicalIndexDirectory);
>
>            for (int i = 0; i < ir.MaxDoc(); i++)
>            {
>                list.Add(ir.Document(i));
>            }
>
>            return list;
>        }
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message