Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List all article-replies #129

Closed
MrOrz opened this issue Jul 24, 2019 · 2 comments
Closed

List all article-replies #129

MrOrz opened this issue Jul 24, 2019 · 2 comments

Comments

@MrOrz
Copy link
Member

MrOrz commented Jul 24, 2019

https://g0v.hackmd.io/SLdQ6HlETYO4NWmfVYsB1g

之後想要做一個 article reply 列表,比較能反映大家的 contribution
要 notify 使用者來看的話,有這樣的列表也是好事
另外還可以加上有用 / 沒用程度 filter

@MrOrz
Copy link
Member Author

MrOrz commented Jan 28, 2020

Implementation findings:

根據目前的 db mapping ( https://beta.hackfoldr.org/1yXwRJwFNFHNJibKENnLCAV5xB8jnUvEwY_oUq-KcETU/https%253A%252F%252Fhackmd.io%252Fs%252FBkxbQ8ZbM )
當時因為 query 速度所以把 articleReply 設計成 articles 底下的 nested object 而沒有選擇 parent/child ( https://www.elastic.co/guide/en/elasticsearch/guide/current/parent-child-performance.html
但實際上我們不常用 nested query,現在反而需要 articleReply 列表,nested object 沒辦法做到這個囧

看起來 nested aggregation + terms sub-aggregation 有機會可以做到「列出 nested object “articleReply”」但不支援 sorting 與 pagination ⋯⋯
image

有一個加強版 terms aggregation 叫做 composite aggregation
https://www.elastic.co/guide/en/elasticsearch/reference/6.3/search-aggregations-bucket-composite-aggregation.html
但似乎要到 ES7 才支援把 composite aggregation 放在 nested aggregation 之下,而我們正在用 ES6.2.3:
elastic/elasticsearch#28611

ES7 看起來確實可以達成我們要的東西

  • 列出所有 articleReply
  • sort by articleReplycreatedAt
  • 可以翻頁(cursor-based)

ES7 做不做得到還有待研究:

image

另外,若不升 ES7 (不做 articleReply list) 可以考慮加強現有 article filter:

  • "最近 (i.e. 某段時間內) 有回應的文章" (nested query 可過濾)
  • "被某人回應的文章" (nested query 可過濾, related issue: List all replies for any editors #60 )
  • sort by "最近回應" - sort 可以 by nested filed 並且指定 (aggregation) mode;也可以 filter
  • "有負評回應的文章" (nested query 可過濾)
  • article 的 articleReplies 只列出 nested query 有 hit 的 articleReply - 使用 articleReply 改使用 innerHits 回傳的東西而非直接讀取所有 articleReplies

@MrOrz
Copy link
Member Author

MrOrz commented May 11, 2020

Replaced by ListArticle, no longer needs root-level article-reply list

@MrOrz MrOrz closed this as completed May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant