Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: support index manager APIs for firestore #7737

Closed
joaqo opened this issue Apr 5, 2024 · 2 comments · Fixed by #7910
Closed

feature request: support index manager APIs for firestore #7737

joaqo opened this issue Apr 5, 2024 · 2 comments · Fixed by #7910
Labels
help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. plugin: firestore Firebase Cloud Firestore type: enhancement Implements a new Feature Workflow: Needs Review Pending feedback or review from a maintainer.

Comments

@joaqo
Copy link
Contributor

joaqo commented Apr 5, 2024

Hi, I was just wondering if there is documentation for the Index Manager introduced around September 2023 in the official SDK?

@mikehardy I saw you commenting on their original PR, so I am assuming it got implemented here as well?

Thanks!

@joaqo joaqo added help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. Type: Docs labels Apr 5, 2024
@mikehardy
Copy link
Collaborator

Hey @joaqo - I investigated that one but never got a reply on that query, so I did not complete any implementation work here - it has sat idle sense then

Documented above now - just not with the capital P - https://firebase.google.com/docs/reference/ios/firebasefirestore/api/reference/Classes/FIRFirestore#persistentcacheindexmanager

So, nothing blocking implementation here as it exists on web (for API shape) and android+ios (for underlying implementation)

Does not exist here as an implementation yet though - I'll leave this open with a slightly altered title, and would happily collaborate on getting a PR in that implemented it

@mikehardy mikehardy changed the title Is there documentation for the Index Manager? feature request: support index manager APIs for firestore Apr 10, 2024
@mikehardy mikehardy added plugin: firestore Firebase Cloud Firestore type: enhancement Implements a new Feature help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. and removed Type: Docs help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. labels Apr 10, 2024
@joaqo
Copy link
Contributor Author

joaqo commented Jun 8, 2024

Hi @mikehardy, been looking into the issue a bit, and it seems the Firebase team is converging towards a really simple API for this. From their docs:

NOTE: This preview method will be deprecated in a future major release. Consider using PersistentCacheIndexManager.enableIndexAutoCreation() to let the SDK decide whether to create cache indexes for queries running locally.

So it seems like it would just be exposing a boolean to turn on/off the auto index creation, at least to get the basic feature running.

I tried to make it work but I'm failing hard without any Objective-C knowledge, little knowledge about React Native's backend, and no familiarity with how RNFB works behind the scenes. Following their docs, this is what I have tried adding to RNFBFirestore/RNFBFirestoreCommon.m:

  • Add to imports:
#import <FirebaseFirestoreInternal/FIRPersistentCacheIndexManager.h>
  • Add to (void)setFirestoreSettings:(FIRFirestore *)firestore appName: right after firestore.settings = firestoreSettings;:
    FIRPersistentCacheIndexManager *indexManager = [FIRFirestore firestore].persistentCacheIndexManager;
    if (indexManager) {
        // Indexing is disabled by default
        [indexManager enableIndexAutoCreation];
    }

My app runs with this code just fine, but I'm not seeing any difference in performance. Just wanted to share this with you in case this is something trivial for you to implement, as I've been struggling with it myself quite a bit.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: good-first-issue Issues that are non-critical issues & well defined for first time contributors. plugin: firestore Firebase Cloud Firestore type: enhancement Implements a new Feature Workflow: Needs Review Pending feedback or review from a maintainer.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants