tags:

views:

183

answers:

1

Hello, I am working on a windows application using Lucene. I want to get all the indexed keywords and use them as a source for a auto-suggest on search field. How can I receive all the indexed keywords in Lucene? I am fairly new in C#. Code itself is appreciated. Thanks.

A: 

Are you looking extract all terms from the index?

private void GetIndexTerms(string indexFolder)
{
    List<String> termlist = new ArrayList<String>();
    IndexReader reader = IndexReader.open(indexFolder);
    TermEnum terms = reader.terms();
    while (terms.next()) 
    {
      Term term = terms.term();
      String termText = term.text();
      int frequency = reader.docFreq(term);
      termlist.add(termText);
    }
    reader.close();
}
Mikos
This is very helpful. Thank you.