I tried my best with the search function and not really getting the results I´m searching for.

At the moment I try to replicate a functionality for swiping profiles on a card stack. The profiles are loaded over a Firebase Firestore backend. The problem is, due to the geoFireStore query, I get with every load within a specific radius a whole bunch of documents and I would like to reduce the read amount directly in the query.

So what I'm trying to achieve is, that when I swiped a profile once (left or right) I never want to read it in the query again. In addition, to save reads, I don't want to do this client sided, it should be done in the query directly.

Firestore JSON structure at the moment:

  • Users (collection)
    • UIDs [documents]
      • name
      • active
      • match {map}

If the match map doesn't contain the own UID (if exist is null) then read in query, else when own UID exist in other user profile under the map match (boolean: true or false for liked or disliked) then don't show as query result.

My stream is built this way:

return geo
    .collection(
        collectionRef:
            friendrCollection.where("active", isEqualTo: true).where("match.$uid", isNull: true))
    .within(
        center: geoFirePoint,
        radius: suchRadius,
        field: 'position',
        strictMode: false)
    .map(_friendrsGPSListFromSnapshot);

}

I am working on this for 3 weeks now and not getting the results I want :D

-Should I stay with firestore or better the real-time-database? -How do I need to structure the data to get a "except" query working?

Right now it is like:

Collection: Users --> Documents: UIDs --> Match{ownUID}

Thanks in advance

Andreas :)

1

There are 1 best solutions below

0
On

I still not managed to find a proper solution to reduce the number of unnecessary profile reads inside the firestore query.

Has anyone an idea to handle this part?

The only way I found was to lookup existing matches on the client side (extra firestore collection), but that means that I always have to load the whole bundle of profiles and throwing them away afterward :(

Thank you!

Andreas