MichaelSolati/geofirestore-js

Retrieving random document within radius

GigaDroid opened this issue · 1 comments

Let's assume there are 300 documents within a given radius. I only want to get a single random document within this radius. Is there an approach to this problem which wouldn't result in around 300 document reads? Applying .limit(1) would only give me the closest document and not a random one (and still result in 300 document reads? Not sure if I understood the implementation correctly).

I believe I understand the problem but I don't see of a method that doesn't include reading all the documents.

Because the library looks to extend the functionality firestore I'd want the query/logic to be as simple and behave as firestore does.

I don't see how a query like your (just select 1 document randomly that matches a query) would work without the near method, so I do not believe that it can be implemented with the near method.

I'm open to conversation, but I do not think it is possible without reading all docs and does not belong in the scope of the library.