DarshanGowda0 / GeoFlutterFire

:fire:GeoFlutterFire:fire: is an open-source library that allows you to store and query firestore documents based on their geographic location.
https://youtu.be/MYHVyl-juUk
MIT License
305 stars 261 forks source link

Combining with search leads to cursor errors #15

Closed japborst closed 5 years ago

japborst commented 5 years ago

I'm combining search with Geoflutterfire.

For example, when searching for everything that starts with the letter a, I can use the following.

final Firestore firestore = Firestore.instance;
Query filteredRef = firestore.collection(my_collection')
          .where("query", isGreaterThanOrEqualTo: 'a')
          .where("query", isLessThan: 'b')
          .orderBy("query");

GeoFirePoint location = GeoFirePoint(0, 0);
Stream<List<DocumentSnapshot>> stream = geo
        .collection(collectionRef: filteredRef)
        .within(center: location, radius: 100, field: 'location');

However, this leads to the below erorr. I know there are results, so that shouldn't be an issue.

com.google.firebase.firestore.FirebaseFirestoreException: INVALID_ARGUMENT: cursor position is outside the range of the original query

When using only one filter (e.g. isEqual or isGreaterThanOrEqualTo) leads to no errors and works.

DarshanGowda0 commented 5 years ago

Hi @japborst, compound queries with multiple range filters are not supported by cloud firestore as mentioned in the docs. Also, GeoFlutterFire internally uses startAt and endAt, so any compound queries that violate rules by firestore when combining with these won't work as of now.