Ashik
Ashik

Reputation: 1259

Get all stored fields from lucene index using java

I want to show the words stored in Lucene index so that user can select the word and get corresponding documents. I am new to Lucene. Any help is appreciated.

Upvotes: 1

Views: 1002

Answers (1)

rojobo
rojobo

Reputation: 486

The issue is that there is no magic getAllStoredFields() function in Lucene. Lucene stores fields in documents which are then stored in an index, every document in the index can have different fields containing stored fields. You need to retrieve one specific document Like:

Document doc = indexReader.document(docNum); and call doc.getFields(). Then iterate over them and checking field.isStored()

Upvotes: 1

Related Questions