Closed ShehabSN closed 5 years ago
Did you ever find a solution to this problem? Same issue for weeks but never could figure it out so I did an inefficient workaround of using the queried data and trimming it with if statements such as, in your example, after you listen for the stream and get the list of document data:
if (document.data['atEvent']) { listOfDocs.add(document); }
No i haven't, this needs to be addressed since most apps will need an additional query...
It works when you specify position.geohash ascending as one of your index fields
I think the trick is to pass a CollectionReference
to geo.collection
. Calling .where()
on a CollectionRef
returns a Query
object, so if you call .reference()
on the Query
object, it should work. At least, it did for me.
You could do something like:
stream = radius.switchMap((rad) {
var collectionReference = Firestore.instance.collection('users').where('atEvent',isEqualTo: true);
return geo.collection(collectionRef: collectionReference.reference()).within(
center: userLoc, radius: rad, field: 'position');
});
Another person had a similar question:
https://github.com/DarshanGowda0/GeoFlutterFire/issues/47#issuecomment-532479084
@stevenspiel I am going to have to try that out sometime.
It works when you specify position.geohash ascending as one of your index fields
Thanks a lot worked
When i tried to add another criteria checking for the value of a specific field i get this error to create an index. I have created indexes before and for some reason the link provided NEVER works and always sends me to an error page. So i usually create the indexes manually. This time however, it wouldnt work so i am confused as to where i am going wrong with this? This is the error message i am getting :
So atEvent is the name of the field with the boolean and position is a map with geohash and also geopoint, so i tried creating a manual index with atEvent as a field (ascending) and position.geohash as another field (descending) and it wouldnt work. I also tried just using position and atEvent but didnt work either. How would i create this index? The package says that it supports this type of query and gives an example just like mine. This is my code for the query: