lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Cortes <dcor...@fib.upc.edu>
Subject Re: Hits sorted
Date Thu, 13 Oct 2005 08:06:50 GMT
thks but It doesn't work, I tried this
    Hits encontrados=searcher.search(buscar,new Sort("DATE"));

and all my documents have a Field.Keyword called DATE.
If i do the search without sort parameter it returns me a lot of 
results, but if i do the search with sort parameter it doesn't return 
any hits.why?
I thinked that the only thing that I need to use Sort is that the field 
was indexed and not tokenized and in my case is a Field type Keyword.


Mordo, Aviran (EXP N-NANNATEK) wrote:

>Just use the Sort option in the searcher
>http://lucene.apache.org/java/docs/api/org/apache/lucene/search/Searcher
>.html#search(org.apache.lucene.search.Query,%20org.apache.lucene.search.
>Sort)
>
>Aviran
>http://www.aviransplace.com
>
>-----Original Message-----
>From: Daniel Cortes [mailto:dcortes@fib.upc.edu] 
>Sent: Tuesday, October 11, 2005 2:58 PM
>To: java-user@lucene.apache.org
>Subject: 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
>
>
>
>---------------------------------------------------------------------
>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


Mime
View raw message