I ve been stuck with this problem for a few weeks now and I have no idea how to solve it. So basically, my index contains data that looks something like this:
[
{ id: 1, value: "some snippet from a paragraph"},
{ id: 1, value: "some different snippet from the same paragraph" }.
{ id: 1, value: "some different snippet from the same paragraph" },
{ id: 2, value: "some snippet from a different paragraph" },
{ id: 2, value: "some different snippet from id no.2 s paragraph " },
... and a few more million values
]
如你所知,“一款”分为多层。 每个项目都有相同的识别资料,但具有不同的价值。
I used $top and $skip, but the problem with this is that the values in the top n results will contain "duplicates". Like, the top 50 results will contain multiple items that have an ID of 1. What I want to happen is that the top n results should only contain items with unique ID s. Is it possible to just get the item with the highest score of each ID? How can I make this happen?
成果应如此:
[
{ id: 1, value: "some value" },
{ id: 2, value: "some value" }.
{ id: 3, value: "some value" },
{ id: 4, value: "some value" },
{ id: 5, value: "some value" },
...
]