FAQ
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

Search Discussions

  • Michael McCandless at Aug 23, 2010 at 3:04 pm
    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 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
  • Erdinc Akkaya at Aug 23, 2010 at 3:08 pm
    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 <ryantxu@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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedAug 23, '10 at 2:58p
activeAug 23, '10 at 3:08p
posts3
users3
websitelucene.apache.org

People

Translate

site design / logo © 2022 Grokbase