16-Aug-05 (Created: 16-Aug-05) | More in 'Lucene'

lucene: How to get all the field names in an index


public void printFieldNames() throws IOException
{
	Collection fieldNames = getReader().getFieldNames();
	Iterator itr = fieldNames.iterator();
	while(itr.hasNext())
	{
		Log.log((String)itr.next());
	}
}

An index reader has a getFieldNames() method. This will return an iterator of strings representing the field names.