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