You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by lampa24 <Kr...@gmail.com> on 2012/02/18 17:19:21 UTC

Sort in PrefixQuery

Hello,
I use lucene. I indexed documents with two fields. First field is name and
second field is count. I use this index for autocomplete. I need find 10
names by prefix and the higest count.
I use code like this :
       
Sort sort = new Sort(new SortField("countfieldname", SortField.INT,true));
PrefixQuery pq = new PrefixQuery(new Term("namefieldname", "prefix"));
indexSearcher.Search(pq,null,10, sort);

But it doesn't work . I get unsorted results. 

--
View this message in context: http://lucene.472066.n3.nabble.com/Sort-in-PrefixQuery-tp3756573p3756573.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

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


Re: Sort in PrefixQuery

Posted by Erick Erickson <er...@gmail.com>.
Please post this question over on the user's list, see the first entry at:
http://lucene.apache.org/solr/discussion.html. This list is intended for
development discussions centered around changes in the actual
code rather than usage questions...

When you do post over there, please include significantly more details,
especially how you index. In particular, what results you *do* get...

Best
Erick

On Sat, Feb 18, 2012 at 11:19 AM, lampa24 <Kr...@gmail.com> wrote:
> Hello,
> I use lucene. I indexed documents with two fields. First field is name and
> second field is count. I use this index for autocomplete. I need find 10
> names by prefix and the higest count.
> I use code like this :
>
> Sort sort = new Sort(new SortField("countfieldname", SortField.INT,true));
> PrefixQuery pq = new PrefixQuery(new Term("namefieldname", "prefix"));
> indexSearcher.Search(pq,null,10, sort);
>
> But it doesn't work . I get unsorted results.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Sort-in-PrefixQuery-tp3756573p3756573.html
> Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>

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