This is what I used to get all field names in an index...
// Returns the union of every document field in the index.
public String[] getAllFields() throws IOException
{
Hashtable fields = new Hashtable();
Vector v = new Vector();
IndexReader reader = IndexReader.open(m_sIndexPath);
for (int i=0; i<reader.numDocs(); i++)
{
Document doc = reader.document(i);
Enumeration enum = doc.fields();
while (enum.hasMoreElements())
{
Field f = (Field)enum.nextElement();
String name = f.name();
if (fields.get(name) != null) // already recorded it
continue;
else
{
// new field, add it to the list
fields.put(name, name);
insertSorted(v, name);
}
}
}
John Piekos
--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@;jakarta.apache.org>