algolia / firestore-algolia-search

Apache License 2.0
112 stars 35 forks source link

Unable to sync firestore record #43

Closed ipranjal closed 3 years ago

ipranjal commented 3 years ago

I used the "import existing documents" section from firebase extension and it gives the following error

{"severity":"ERROR","message":"Error when performing Algolia index Error: Value for argument \"collectionPath\" is not a valid resource path. Path must be a non-empty string.\n    at Object.validateResourcePath (/Users/physcocode/.npm/_npx/0ca4ecfa9810ae5b/node_modules/@google-cloud/firestore/build/src/path.js:414:15)\n    at Firestore.collection (/Users/physcocode/.npm/_npx/0ca4ecfa9810ae5b/node_modules/@google-cloud/firestore/build/src/index.js:561:16)\n    at retrieveDataFromFirestore (/Users/physcocode/.npm/_npx/0ca4ecfa9810ae5b/node_modules/firestore-algolia-search/lib/import/index.js:45:42)\n    at /Users/physcocode/.npm/_npx/0ca4ecfa9810ae5b/node_modules/firestore-algolia-search/lib/import/index.js:75:9\n    at Interface._onLine (readline.js:335:5)\n    at Interface._line (readline.js:666:8)\n    at Interface._ttyWrite (readline.js:1010:14)\n    at ReadStream.onkeypress (readline.js:213:10)\n    at ReadStream.emit (events.js:315:20)\n    at emitKeys (internal/readline/utils.js:345:14)"}
smomin commented 3 years ago

Hey ipranjal, you're not providing enough information for me to action against. can you provide complete details so I can try to recreate the issue.

anujraghuvanshi commented 3 years ago

Hi @smomin - I am also facing the same issue. Earlier on Firestore extensions I configured some indices with algolia with firestore extension v0.3.0 and it was getting sync to Algolia smoothly.

Yesterday I configured some more collections from firestore to be synced to Algolia which is created by Extension v0.4.1 and they are not getting synced to Algolia.

So seems its issue with updated version of Firebase Algolia Extension.

smomin commented 3 years ago

is this the import process or the real time indexing issue? can you provide me the configuration without the apiKey?

smomin commented 3 years ago

hello, i have tested this out on my local and as well on my Cloud Firestore. I was able to import to a clean Algolia Index. I was able to make changes to data in my firestore collection and see the updates come through fine. Am I missing anything here?

ipranjal commented 3 years ago

@smomin sorry for late reply let me run the query and let you know exactly by EOD

smomin commented 3 years ago

@ipranjal if you can create a video of the issue, it will help me get this recreated and quickly get it fixed.

smomin commented 3 years ago

Please provide the collectionPath and fields configuration.

ipranjal commented 3 years ago

Step 1

Command I typed :

 LOCATION=asia-south1\         
  ALGOLIA_APP_ID=Q********W\
  ALGOLIA_API_KEY=718****************************70\
  ALGOLIA_INDEX_NAME=shops\
  COLLECTION_PATH=shops\
  GOOGLE_APPLICATION_CREDENTIALS=*****/Downloads/firebase-adminsdk.json
  npx firestore-algolia-search

Output I got :

{"severity":"WARNING","message":"Warning, FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail"}
{"algoliaAPIKey":"********","severity":"INFO","message":"Initializing extension with configuration"}

Step 2

WARNING: The back fill process will index your entire collection which will impact your Search Operation Quota.  Please visit https://www.algolia.com/doc/faq/accounts-billing/how-algolia-count-records-and-operation/ for more details.  Do you want to continue? 

Answer : yes

Output:

{"severity":"ERROR","message":"Error when performing Algolia index Error: Value for argument \"collectionPath\" is not a valid resource path. Path must be a non-empty string.\n    at Object.validateResourcePath (/Users/physcocode/.npm/_npx/0ca4ecfa9810ae5b/node_modules/@google-cloud/firestore/build/src/path.js:414:15)\n    at Firestore.collection (/Users/physcocode/.npm/_npx/0ca4ecfa9810ae5b/node_modules/@google-cloud/firestore/build/src/index.js:561:16)\n    at retrieveDataFromFirestore (/Users/physcocode/.npm/_npx/0ca4ecfa9810ae5b/node_modules/firestore-algolia-search/lib/import/index.js:45:42)\n    at /Users/physcocode/.npm/_npx/0ca4ecfa9810ae5b/node_modules/firestore-algolia-search/lib/import/index.js:75:9\n    at Interface._onLine (readline.js:335:5)\n    at Interface._line (readline.js:666:8)\n    at Interface._ttyWrite (readline.js:1010:14)\n    at ReadStream.onkeypress (readline.js:213:10)\n    at ReadStream.emit (events.js:315:20)\n    at emitKeys (internal/readline/utils.js:345:14)"}
ipranjal commented 3 years ago

Snapshot of collection In firestore

Screenshot 2021-06-26 at 12 37 01 AM

Firestore Secutity rule:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if
          request.time < timestamp.date(2021, 7, 14);
    }
  }
}
ipranjal commented 3 years ago

@smomin let me know if I am missing any information you require :)

ipranjal commented 3 years ago

Just incase , here is my api key generation with all appropriate permissions

Screenshot 2021-06-26 at 12 45 51 AM
ipranjal commented 3 years ago

@smomin I also noticed this looks somewhat similar to #42 I am not sure though that we are facing the same problem

Note : Both firebase project and Algolia project are freshly made on the day I reported this issue

smomin commented 3 years ago

Hey @ipranjal, thanks for sending all this information. Now looking at everything. I see the issue. The error you are getting is the Collection Path is not set. From your CLI command, you are missing \ at the end of the GOOGLE_APPLICATION_CREDENTIALS location string. Here is the correct command:

 LOCATION=asia-south1\         
  ALGOLIA_APP_ID=Q********W\
  ALGOLIA_API_KEY=718****************************70\
  ALGOLIA_INDEX_NAME=shops\
  COLLECTION_PATH=shops\
  GOOGLE_APPLICATION_CREDENTIALS=*****/Downloads/firebase-adminsdk.json\
  npx firestore-algolia-search

Please let me know if this resolve the issue. Thanks.

smomin commented 3 years ago

@ipranjal is this is fixed, can we close this issue.

ipranjal commented 3 years ago

@smomin I tried it but still the same issue :'(

Screenshot 2021-06-29 at 2 05 03 AM
smomin commented 3 years ago

Hey @ipranjal, lets try the below single line command:

LOCATION=asia-south1 ALGOLIA_APP_ID=Q********W ALGOLIA_API_KEY=718****************************70 ALGOLIA_INDEX_NAME=shops COLLECTION_PATH=shops FIELDS= GOOGLE_APPLICATION_CREDENTIALS=*****/Downloads/firebase-adminsdk.json npx firestore-algolia-search@0.4.1
ipranjal commented 3 years ago

@smomin weird, it worked out as single line command , am closing this issue for now, here are my spec where I was running the command

OS : MacOS Big Sur Terminal: zsh