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 Daniel Cortes <dc...@fib.upc.edu> on 2005/10/11 20:58:29 UTC

Hits sorted

Hi everybody, I have a problem when I find all the documents added in 
the last days in my index. It works good but I want show this results 
sorted. What I have to do?

My code is this:

    private RangeQuery findINTODates(int days) {
        Term from;
        Term to;

        Calendar calendar = new GregorianCalendar();
        calendar.add(Calendar.DATE,-(days));
       
        SimpleDateFormat originalFormatter = new SimpleDateFormat 
("yyyyMMdd");
        from = new 
Term("DATE",originalFormatter.format(calendar.getTime()));
        to = new Term("DATE",originalFormatter.format(new Date()));

        RangeQuery lastdays= new RangeQuery(from,to,true);

        return lasdays;
    }

and I call this

    Hits returned=searcher.search(findINTODates(num_days));

What I have to do? I have to use DateFilter or Sort elements ?  I don't 
know how to work with these classes.
In mMy documents of lucene I added the field Date how a string and not 
how a date because it's more easy for add documents to index in my case.

thks for all.



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org