You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by "O'Hare, Thomas" <to...@akamai.com> on 2004/07/09 04:27:41 UTC
Browse by Letter within a Category
I would like to implement the following functionality:
- Search a specific field (category) and limit the search where the
title field begins with a given letter, and return the results sorted in
alphabetical order by title. Both the category and title fields are
tokenized, indexed and stored in the index (type Field.Text). How should
I construct the search and sort? I tried the following, but the titles
are not being displayed in alphabetical order:
Searcher.search("category:\"Products\" AND title:\"A*\"", new
Sort("title"));
I want to display all results where Products is the category whose title
begins with the letter A, sorted in alphabetical order by title. I'm
using Lucene 1.4 final release.
Thanks,
Tom
Re: Browse by Letter within a Category
Posted by Daniel Naber <da...@t-online.de>.
On Friday 09 July 2004 04:27, O'Hare, Thomas wrote:
> Searcher.search("category:\"Products\" AND title:\"A*\"", new
> Sort("title"));
You can only sort on fields which are not tokenized I think. So add an extra
field with the title, but untokenized, just for sorting. Also, "A*" might
slow down the query execution so you might want to add another field which
just contains the first letter so there's no need for the asterisk.
Regards
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org