klakekent

如何筛选帖子评论赞同数量最高的那条数据?

  •  
  •   klakekent · Mar 30, 2018 · 9346 views
    This topic created in 3142 days ago, the information mentioned may be changed or developed.
    es 里面每条数据结构如下

    postid,commentid,comment,starts
    1 1 ×××× 3
    1 2 ×××× 4
    2 3 ×××× 1
    2 4 ×××× 0


    我想选出来每一个帖子下面的评论 starts 最高的一条该怎么做呢?
    6 replies  •  2018-06-03 13:38:09 +08:00
    klakekent
    klakekent
    OP
    Mar 30, 2018
    1
    我想得到的结果大概就是
    1 2 ××× 4
    2 3 ××× 1
    zhangfeiwudi
    zhangfeiwudi
    Mar 30, 2018
    2
    group on + order by 可行否?
    klakekent
    klakekent
    OP
    Mar 30, 2018
    3
    我发现用 aggs 和 top_hits 组合会有个问题,就是比如我的 postid 有 6 条评论,但是通过这个方式选出来显示 total 数量不足 6 条
    turan12
    turan12
    Mar 30, 2018
    4
    max(stars) + group by postid
    Hieast
    Hieast
    Mar 31, 2018 via Android
    5
    使用 terms postid 桶,每个桶里取 max starts
    klakekent
    klakekent
    OP
    Jun 3, 2018
    6
    解决 用 collapse 很简单
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2602 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:08 · PVG 22:08 · LAX 06:08 · JFK 09:08
    ♥ Do have faith in what you're doing.