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 Ryan McKinley <ry...@gmail.com> on 2010/08/23 16:57:14 UTC
reverse TermsEnum (/trunk)?
Is there anyway to walk the terms in reverse order?
I have a query that need to find the last matching term -- if it could
start checking from the end, it would avoid a lot of work.
Thanks
Ryan
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: reverse TermsEnum (/trunk)?
Posted by Erdinc Akkaya <hz...@gmail.com>.
hmm you can try creating
Sort sort = null;
SortField[] sortFields = new SortField[1];
sortFields[0] = new SortField(FIELD_TO_SEARCH, LOCALE,true**);
sort = new Sort(sortFields);
** org.apache.lucene.search.SortField<eclipse-javadoc:%E2%98%82=SearchIndexWeb/%5C/var%5C/www%5C/SearchIndexWeb%5C/WebContent%5C/WEB-INF%5C/lib%5C/lucene-core-3.0.2.jar%3Corg.apache.lucene.search%28SortField.class%E2%98%83SortField>
.SortField(String<eclipse-javadoc:%E2%98%82=SearchIndexWeb/%5C/var%5C/www%5C/SearchIndexWeb%5C/WebContent%5C/WEB-INF%5C/lib%5C/lucene-core-3.0.2.jar%3Corg.apache.lucene.search%28SortField.class%E2%98%83SortField%7ESortField%7ELjava.lang.String;%7ELjava.util.Locale;%7EZ%E2%98%82String>field,
Locale<eclipse-javadoc:%E2%98%82=SearchIndexWeb/%5C/var%5C/www%5C/SearchIndexWeb%5C/WebContent%5C/WEB-INF%5C/lib%5C/lucene-core-3.0.2.jar%3Corg.apache.lucene.search%28SortField.class%E2%98%83SortField%7ESortField%7ELjava.lang.String;%7ELjava.util.Locale;%7EZ%E2%98%82Locale>locale,
boolean reverse)
if you set last variable true it will walk reverse order.
then give it to Searcher object as a sort parameter
Searcher searcher = null;
TopFieldDocs topFieldDocs = searcher.search(query, AMOUNT_YOU_WANT, sort);
2010/8/23 Ryan McKinley <ry...@gmail.com>
> Is there anyway to walk the terms in reverse order?
>
> I have a query that need to find the last matching term -- if it could
> start checking from the end, it would avoid a lot of work.
>
> Thanks
> Ryan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
--
Erdinc Akkaya
Web Developer @ CE / Positive
www.positive.com.tr
Re: reverse TermsEnum (/trunk)?
Posted by Michael McCandless <lu...@mikemccandless.com>.
I don't think there is a way....
The only thing I can think of is to reverse your term comparator (flex
lets you specify a custom term order); then the terms are indexed in
reversed order and your first term is the "last".
You can seek by ord though. So you could seek backwards by moving the
ord backwards, but, this will be severely inefficient
Mike
On Mon, Aug 23, 2010 at 10:57 AM, Ryan McKinley <ry...@gmail.com> wrote:
> Is there anyway to walk the terms in reverse order?
>
> I have a query that need to find the last matching term -- if it could
> start checking from the end, it would avoid a lot of work.
>
> Thanks
> Ryan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org