-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: problem with sorting on numeric value
PostPosted: Wed Apr 04, 2012 7:31 am 
Newbie

Joined: Mon Feb 01, 2010 2:42 pm
Posts: 3
Hi

I have this model (1 entity and two components)

Code:
@Entity
@Indexed
class Advert {

    @Column(name = "text", length = 10000)
    @Field(analyze = Analyze.YES, index = Index.YES, store = Store.YES, norms = Norms.YES, termVector = TermVector.NO, boost = @Boost(4f), indexNullAs = Field.DO_NOT_INDEX_NULL)
    @Size(max = 10000)
    private String text;
   
   
    @Embedded
    @IndexedEmbedded
    private AdvertAdm advertAdm;

}

@Embeddable
public class AdvertAdm {

    @Embedded
    @IndexedEmbedded
    private AdvertAdmData advertAdmData;

}

@Embeddable
public class AdvertAdmData {

    @NumericField (precisionStep = 8)
    @Column(name = "cal_longStartOn")
    @Field(name = "cal_longStartOn",  analyze = Analyze.NO, index = Index.YES, store = Store.NO, norms = Norms.NO, termVector = TermVector.NO, boost = @Boost(1f), indexNullAs = Field.DO_NOT_INDEX_NULL)
    private long longStartOn;

}


I can do a search like that

Code:
Query luceneQuery = queryBuilder
   .bool()
   .must(queryBuilder.keyword()
         .onFields("text")
         .matching(textToSearch)
         .createQuery())
   .must(queryBuilder
         .range()
         .onField("advertAdm.advertAdmData.cal_longStartOn")
         .below(1000L)
         .createQuery())
   .createQuery();


Now when I want to sort it, I don't know how o do it.
I try that but nothing change in the result:

Code:
org.apache.lucene.search.Sort sort = new Sort(new SortField("cal_longStartOn", SortField.LONG, true));
fullTextQuery.setSort(sort);


I have also tried
Code:
org.apache.lucene.search.Sort sort = new Sort(new SortField("advertAdm.advertAdmData.cal_longStartOn", SortField.LONG, true));
fullTextQuery.setSort(sort);   


Do I need to put both @NumericField and @Field annotation ?
because I need to search and sort on this field.

Do I need to write
Code:
precisionStep = 8
as I need to use long

Do you have any idea on what I am missing ?
Thanks for your help

François


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.