是否有任何解决方法排序多值字段? [英] Is there any workaround for sorting on multiValued field?

查看:119
本文介绍了是否有任何解决方法排序多值字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可以在文档的分数或任何multiValued =falseindexed =true字段上完成排序,前提是该字段是非标记化的(即:没有分析器)或使用仅产生一个单词的分析器(即:使用KeywordTokenizer)

docs: - http://wiki.apache.org/solr/CommonQueryParameters#sort



我的原始模式是(您可以考虑以下是GROUP-BY): -
$ b


  • products(id,独特的)

    • 为每个用户提供一些评论(多值)

    • last_comment_date的用户(multiValued,一个用户可以发表多个评论,但只有最后的评论日期被捕获)

      $ b

      如果允许在multiValued上进行排序,

      我可以轻松获得某些用户评论的产品列表,

      然后按last_activity_da排序te

      然而,它不起作用。

      我目前的解决方法是将模式反转为: -




      • 用户+产品(作为ID,唯一)

      • 用户(单值) li> last_comment_date

      • 产品



      产品由某些用户评论,

      由last_comment_date订购,

      当然会导致产品重复产品

      出现在每个用户的评论中。



      任何建议来模拟分组效果。



      我使用solr 3.1。

      字段崩溃不适用。

      解决方案

      按多值字段排序是不是只是待做或可以修补的东西。



      它不可能完成,因为它根本没有任何意义。



      这样做是为每个文档创建一个单值字段(在索引时填入最后一个日期),然后对其进行排序。即当索引遍历用户列表的最后活动日期时,查找最新日期并将其分配给文档的最后活动日期字段。

      Sorting can be done on the "score" of the document, or on any multiValued="false" indexed="true" field provided that field is either non-tokenized (ie: has no Analyzer) or uses an Analyzer that only produces a single Term (ie: uses the KeywordTokenizer)

      docs:- http://wiki.apache.org/solr/CommonQueryParameters#sort

      My original schema is (You can consider the following is a GROUP-BY) :-

      • products (id, unique)
        • users who make some comments(multiValued)
        • last_comment_date for each user (multiValued, one user can make multiple comments, but only the last comment date is captured)

      If sorting on multiValued is allowed,
      I can easily get list of the products commented by certain users,
      then sort by last_activity_date.

      However, it does not work.
      The workaround I have currently is to reverse the schema to :-

      • user + product (as id, unique)
      • user (single value)
      • last_comment_date
      • products

      Which mean I (sort of) manage to get list of the products commented by certain users,
      order by last_comment_date,
      of course it lead to duplication of products
      as product will appear in each of the user's comment.

      Any suggestion to simulate a group-by effect.

      Between, I using solr 3.1.
      Field collapsing does not apply.

      解决方案

      Sorting by a multi-valued field is not something that is just pending to do or can be patched.

      It can't be possibly done because it simply doesn't make any sense.

      The way to do this is to have a single-valued field (populated at index-time with the last date) per document, then sort on that. I.e. when indexing traverse the list of users with their last activity date, find the latest date, and assign it to the document's last-activity-date field.

      这篇关于是否有任何解决方法排序多值字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆