Reputation: 498
I need to populate a dropdown with all field names in a lucene index and need to show those values. I was able to do it successfully using
var luceneIndexReader IndexReader.Open("D:\path_to\index_directory", true);
var allAvailableFieldNames = luceneIndexReader.GetFieldNames(IndexReader.FieldOption.ALL);
Only problem is I need to include only 'Stored' fields in the drop down. This list includes all 'Indexed' and/or 'Stored' fields in it. Is there a way to query/search the indexes if a field has any 'stored' values and thereby filter out this list?
Upvotes: 6
Views: 5517
Reputation: 12859
Late at the party, but in the meanwhile you can just call FieldInfos# GetEnumerator()
Upvotes: 0
Reputation: 1395
The problem is that every document in the index can have different fields containing stored fields. Since those are not storef as inverted index (they are stored per document) you can't retrieve them from the IndexReader. You need to retrieve one specific document, e.g. Document doc = indexReader.document(1);
and call Fieldable fields[] = doc.getFields();
. Then iterate over them and checking: field.isStored();
.
Upvotes: 6