对 multiValued 字段进行排序是否有任何解决方法?

编程入门 行业动态 更新时间:2024-10-21 13:27:32
本文介绍了对 multiValued 字段进行排序是否有任何解决方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可以对文档的分数"或任何 multiValued="false" indexed="true" 字段进行排序,前提是该字段是非标记化的(即:没有分析器)或使用的分析器只产生一个 Term(即:使用 KeywordTokenizer)

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)

文档:- wiki.apache/solr/CommonQueryParameters#sort

我原来的模式是(你可以认为下面是一个GROUP-BY):-

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

  • 产品(id,唯一)
    • 发表评论的用户(multiValued)
    • 每个用户的last_comment_date(multiValued,一个用户可以进行多条评论,但只捕获最后一条评论的日期)

    如果允许对 multiValued 进行排序,我可以轻松获取某些用户评论的产品列表,然后按 last_activity_date 排序.

    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 :-

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

    这意味着我(某种程度上)设法获得了某些用户评论的产品列表,按 last_comment_date 排序,当然会导致产品重复因为产品会出现在每个用户的评论中.

    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.

    在此之间,我使用的是 solr 3.1.字段折叠不适用.

    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.

    这样做的方法是为每个文档设置一个单值字段(在索引时间填充最后一个日期),然后对其进行排序.IE.索引时遍历具有上次活动日期的用户列表,找到最新日期,并将其分配给文档的上次活动日期字段.

    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.

更多推荐

对 multiValued 字段进行排序是否有任何解决方法?

本文发布于:2023-05-28 12:30:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/320941.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:词库加载错误:Could not find file 'D:\淘小白 高铁采集器win10\Configuration\Dict_Sto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!