lucene排序问题

 

The fields used to determine sort order must be carefully chosen. 

选择排序字段一定要细心。

Documents must contain a single term in such a field, and the value of 

the term should indicate the document's relative position in a given 

sort order.

用于排序的字段在文档当中必须只能含有单一的term,并且这个term的值应该能够准确的准确的定位当前文档在排序中的位置

 

The field must be indexed, but should not be tokenized, and 

does not need to be stored (unless you happen to want it back with the 

rest of your document data).

这个字段必须被索引,但是不能被分词,并且不是必须存储的(除非你碰巧希望它返回你文档的剩余字段)

 

In other words: 也就是说:

document.add (new Field ("byNumber", Integer.toString(x), Field.Store.NO, Field.Index.NOT_ANALYZED)); 

 

 

 

 

 

If I want to sort some field (for example name is "TITLE") and It must be Analyzed. 

 

Then Do I have to make two field that one is ANALYZED and the other is NOT_ANALYZED like this? 

 

document.add(new Field("TITLE", value, Field.Store.NO. Field.Index.ANALYZED) 

document.add(new Field("TITLE_FOR_SORT", value, Field.Store.NO, Field.Index.NOT_ANALYZED) 

 

that is right!

 

 

sort构造方法:

Sort() 
          Sorts by computed relevance.通过计算相关性排序

Sort(SortField... fields) 
          Sorts in succession by the criteria in each SortField.按照多个字段排序

Sort(SortField field) 
          Sorts by the criteria in the given SortField.指定单个字段排序

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值