c# - Querying by near, sorting, then paging -
I am using the geospatial "closest" search in MongoDB (using the C # driver) given the long / Long it kills homes / prolongs proximity and works great
However, I want to add to the sorting (other areas such as house prices) and paging and here I Where am I stuck. To work correctly, it will be necessary to find out which homes are latitude / long within 25 miles, then sort those results (we say on value basis), and then 10 Take a "page" of the results.
The problem with what I have done so far is that the page of results takes (based on proximity sort) and then I set the 10 result page in "SetSource Order" , Which is instead of sorting the whole result to late / long, so each page of 10 results is sorted in itself.
var coordinate = find.GetCoordinates (); Var close = query Neer ("coordinate", coordinate, latitude, coordinate, length, search. GetRadiansAway (), incorrect); Var query = archive (). Find (near); Query.Skip = find.GetSkip (); Query.Limit = find.GetLimit (); Query.SetSortOrder (new string [] {"value"}); Var result = query. ToArray ();
This is the correct behavior, because by default the return result is sorted by distance And is automatically trimmed in the dollar near the operator, so you can not change it.
db.places.find ({loc: {$ near: [50,50]}})
Find the nearest number of queries above (50,50) and Sort them by distance (no extra sort parameters are needed)
Then you have example in value this is the second type of area which results There is sorted data within HTML>
Comments
Post a Comment