See TermEnum (I don't think you need TermDocs for this). If you instantiate a TermEnum(new Term("firstletterfield", "")), it'll enumerate all the terms in your 'firstletter' field and you can just collect them and go...
For that matter, and assuming that your names are UN_TOKENIZED, you could do something like this without a special field by iterating over your personName field. This might be reasonable if your index is fairly static and you could create this list at IndexReader open time, especially since you can use TermEnum.skipTo("personName", "a") etc..... Best Erick On 2/23/07, Paul Sundling (Webdaddy) <[EMAIL PROTECTED]> wrote:
I have a requirement to support filtering search results by first letter. This is relatively simple by adding a field to each index that represents the first letter for that relevant index and then adding a filter to the search. The hard part is that I need to list all the letters you can filter BY. So if there are no names that start with S, it shouldn't appear as an option. Is there a simple and performant way to get a set of all the unique values for a Field in the Hits returned? There would probably only be low number of unique values. So let's say I have the following in my index: letter, personName m, mike smith p, paul smith g, george smith g, glenda smith I need to be able to display to the user that they can filter based on M, P or G within their search for George. I could do a compromise and for search results above a certain level, show all letters and numbers, but it won't always give correct values. Imagine this edge case: A search for george has 50,000 results, but only a couple people had george as their last name. Not many of the letters would be valid filters. Thanks for any ideas or approaches I overlooked. Paul Sundling --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]