2017-04-21 53 views
0

我試圖用geoNear和組聚合(其他選項也罰款)做出以下MongoDB的geoNear和組

  1. 收集與loc (2dsphere indexed)user_id領域文件
  2. 有許多是該文件的一個user_id有許多loc

前)

{"user_id":1, "loc": { "type": "Point", "coordinates": ... }} 
{"user_id":1, "loc": { "type": "Point", "coordinates": ... }} 
{"user_id":2, "loc": { "type": "Point", "coordinates": ... }} 
  • 我想使用geoNear與最後插入loc S的每個user_id
  • 我認爲它會與聚集組和geoNear的順序工作,但該文檔告訴geoNear必須比其他人先走。

    我該怎麼做?

    回答

    0

    援引documentation

    您只能使用$ geoNear作爲管道的第一階段。

    這是聚合管道中$geoNear的當前限制。