【问题标题】:Lucene 8 ScoringLucene 8 评分
【发布时间】:2019-12-13 16:54:05
【问题描述】:

我对 Lucene 8 比较陌生,想了解如何将旧版 Solr 4 评分迁移到 Lucene。这就是目前使用 Solr 4 的方式。

  /*
         * From the SolrRelevancyFAQ:
         * How can I see the 0?
         * 
         * Request that the pseudo-field named "score" be returned by adding it
         * to the fl (field list) parameter. The "score" will then appear along
         * with the stored fields in returned documents. q=Justice League&fl=*,score
         */

query.setFields("*", "score");

如何使用 Lucene 8 做到这一点?我宁愿保持简单。 有没有办法像上面那样请求返回的伪字段? 谢谢0

【问题讨论】:

    标签: java lucene


    【解决方案1】:

    我最终实施了以下解决方案:

    searcher.search(query, request.getMaxResults(), new Sort(new SortField(request.getSortOrder().getFieldName(),

    SortField.Type.STRING, request.getSortOrder().isAscending() ?假:真)),真);

    注意:最后一个参数“doDocScores”默认为 false。 完成此操作后,ScoreDoc 将包含该文档的分数。

    【讨论】:

      猜你喜欢
      • 2011-04-04
      • 2010-09-05
      • 2019-05-04
      • 2010-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-12
      • 1970-01-01
      相关资源
      最近更新 更多