I have created the following document:
var document = new Document();
document.Add(new Field("category", "foo", Field.Store.YES, Field.Index.NOT_ANALYZED));
...
I have approx 10M documents which belong to 8 distinct categories. I would like to get all distinct categories (get all documents and read a value of category field) by executing search query. Is that feasible?
Another approach is to create a list of categories at index rebuild and to write these values in database.
Any help would be greatly appreciated!
Check out the IndexReader.Terms() method.
If you give it an empty Term for a field, it will return a TermEnum containing all the terms for that field.