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 <[email protected]> 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; > } > > >
