algolia / firestore-algolia-search

Apache License 2.0
112 stars 35 forks source link

FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail #42

Closed ImanYZ closed 3 years ago

ImanYZ commented 3 years ago

After installing the "Search with Algolia" Firebase extension, the extension page has three tabs: 1- How this extension works 2- Extension configuration 3- APIs and resources

I followed the instructions in first tab "How this extension works". I've copied the instructions that I get on this page below for your reference. After running npx firestore-algolia-search, the first lines of console logs are as follows. {"severity":"WARNING","message":"Warning, FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail"} {"algoliaAppId":,"algoliaAPIKey":"****","algoliaIndexName":"nodesIndex","collectionPath":"nodes","fields":"admin,content,createdAt,nodeType,tags,title","severity":"INFO","message":"Initializing extension with configuration"} 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? (y/N): I answered "y" to this question. Then, it generated a lot of logs but there is no index record generated on Algolia.

You can test out this extension right away:

Go to the Cloud Firestore tab.

If it doesn’t exist already, create a collection called nodes.

Create, update, or delete a document in the nodes collection. Go to Algolia’s dashboard and verify in Algolia that a record is created, updated, or deleted in the nodesIndex index for application id ................

Using the extension This extension listens to the Cloud Firestore collection nodes. If you create, update, or delete a document within that collection, this extension will:

Indexes the document and send all the fields or configured fields defined in the extension. or, removes the record from Algolia index if the document is deleted. (Optional) Import existing documents or Reindex after configuration changes This extension starts monitoring the nodes collection after a successful installation. Any existing documents created before the extension installation can be back-filled into your Algolia nodesIndex Index using the import script. Also, you will need to run the import script if you change the Indexable Fields, Index Name, Application Id, and/or API Key configuration.

The import script will read all existing documents in the nodes collection and insert them into the Algolia nodesIndex index.

Important notes You must run the import script over the entire collection after installing the Search with Algolia extension; otherwise you will have missing records in your Algolia nodesIndex index. lastmodified attributed is added to all Algolia records to eliminate race condition issues related from the Cloud Function cold start. Run the script The script will use the extension configuration before the import process starts.

Run the import process using npx.

Make sure that you’ve installed the required tools to run the import script:

To access the npx command tools, you need to install Node.js. If you use npm v5.1 or earlier, you need to explicitly install npx. Run npm install --global npx. The import script uses Application Default Credentials to communicate with Firebase. Please follow the instructions to generate a key for your service account.

Execute the below command:

Update the path to the Google Application credentials. Clear out the FIELDS param if it contains { unspecified parameter } in the command below since it’s an invalid value. LOCATION=us-east4\ ALGOLIA_APP_ID=\ ALGOLIA_API_KEY=\ ALGOLIA_INDEX_NAME=nodesIndex\ COLLECTION_PATH=nodes\ FIELDS=admin,content,createdAt,nodeType,tags,title\ GOOGLE_APPLICATION_CREDENTIALS=</path/to/service/account/key>\ npx firestore-algolia-search Monitoring As a best practice, you can monitor the activity of your installed extension, including checks on its health, usage, and logs.

smomin commented 3 years ago

Does the API key you are using have the correct permissions?

ImanYZ commented 3 years ago

Yes, it is. The Algolia technical support team gave me instructions to create a new API key with the right permissions and after creating the new API key with the right permissions, I still get the same error.

In addition, I asked two other developers in our team to install the extension and try to use it on test apps. They got the same error.

smomin commented 3 years ago

Can you provide me the error you are getting?

ImanYZ commented 3 years ago

I've put the error message in the very first post in this thread: {"severity":"WARNING","message":"Warning, FIREBASE_CONFIG and GCLOUD_PROJECT environment variables are missing. Initializing firebase-admin will fail"}

ImanYZ commented 3 years ago

It console logs the following for a really long time because our collection is large, but it does not create any Algolia index records.

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? (y/N): {"severity":"DEBUG","message":"[ 'field', 'admin' ]"}
{"severity":"DEBUG","message":"[ 'value', 'RJMaryala' ]"}
{"severity":"DEBUG","message":"[ 'field', 'content' ]"}
{"severity":"DEBUG","message":"[\n  'value',\n  'Park, E., Chiles, C., Cinciripini, P., Foley, K., Fucito, L., Haas, J., . . . Toll, B. (2020, October 13). Impact of the covid‐19 pandemic on telehealth research in cancer prevention and care: A call to sustain telehealth advances. Retrieved February 18, 2021, from https://doi.org/10.1002/cncr.33227'\n]"}
{"severity":"DEBUG","message":"[ 'field', 'createdAt' ]"}
{"severity":"DEBUG","message":"[ 'value', 1613686595408 ]"}
{"severity":"DEBUG","message":"[ 'field', 'nodeType' ]"}
{"severity":"DEBUG","message":"[ 'value', 'Reference' ]"}
{"severity":"DEBUG","message":"[ 'field', 'tags' ]"}
{"severity":"DEBUG","message":"[\n  'value',\n  [ { title: 'SARS-CoV-2 (COVID-19)', node: 'uYgvhNdciHcuK7ioGZEv' } ]\n]"}
{"severity":"DEBUG","message":"[ 'field', 'title' ]"}
{"severity":"DEBUG","message":"[\n  'value',\n  'Impact of the COVID‐19 pandemic on telehealth research in cancer prevention and care: A call to sustain telehealth advances'\n]"}
{"severity":"DEBUG","message":"[ 'field', 'admin' ]"}
{"severity":"DEBUG","message":"[ 'value', 'sohineetsaha' ]"}
{"severity":"DEBUG","message":"[ 'field', 'content' ]"}
{"severity":"DEBUG","message":"[\n  'value',\n  'In late April 2020, the CDC confirmed the first cases of the virus among cats in the USA. Two cats of different households were tested positive in the state of New York. One cat had presumably been infected due to the owner having COVID-19. The other cat, however, had presumably been affected by an asymptomatic or an outside source as no household members tested positive.\\n' +\n    '\\n' +\n    '\\n' +\n    'In early June 2020, the first dog in the USA to test positive for the virus was a German Shepherd in the state of New York. The dog, Buddy, had been infected after one of his owner’s tested positive for the virus. Though he was expected to survive, Buddy died three months after experiencing life-threatening symptoms and one month after being confirmed positive for the virus. However, late awareness of Buddy’s condition with lymphoma currently leaves questions of his ultimate cause of death. \\n' +\n    '\\t\\t\\n' +\n    '\\n'\n]"}
{"severity":"DEBUG","message":"[ 'field', 'createdAt' ]"}
{"severity":"DEBUG","message":"[ 'value', 1597465187755 ]"}
{"severity":"DEBUG","message":"[ 'field', 'nodeType' ]"}
{"severity":"DEBUG","message":"[ 'value', 'Relation' ]"}
{"severity":"DEBUG","message":"[ 'field', 'tags' ]"}
{"severity":"DEBUG","message":"[\n  'value',\n  [ { title: 'SARS-CoV-2 (COVID-19)', node: 'uYgvhNdciHcuK7ioGZEv' } ]\n]"}
{"severity":"DEBUG","message":"[ 'field', 'title' ]"}
{"severity":"DEBUG","message":"[ 'value', 'First Positive Cases in Cats and Dogs in USA' ]"}
{"severity":"DEBUG","message":"[ 'field', 'admin' ]"}
{"severity":"DEBUG","message":"[ 'value', 'Grae' ]"}
{"severity":"DEBUG","message":"[ 'field', 'content' ]"}
{"severity":"DEBUG","message":"[\n  'value',\n  'The process models approach considers information-seeking skills as a necessary piece to the information-seeking process. The lessons are geared more towards bolstering those skills and how to seek information using the library tools. '\n]"}
{"severity":"DEBUG","message":"[ 'field', 'createdAt' ]"}
{"severity":"DEBUG","message":"[ 'value', 1613420452357 ]"}
{"severity":"DEBUG","message":"[ 'field', 'nodeType' ]"}
{"severity":"DEBUG","message":"[ 'value', 'Concept' ]"}
{"severity":"DEBUG","message":"[ 'field', 'tags' ]"}
{"severity":"DEBUG","message":"[\n  'value',\n  [ { title: 'Library Science', node: 'gRRpc1O61kMszcrW07lW' } ]\n]"}
{"severity":"DEBUG","message":"[ 'field', 'title' ]"}
{"severity":"DEBUG","message":"[ 'value', 'The Process Models Approach Instruction Model in ISP' ]"}
{"severity":"DEBUG","message":"[ 'field', 'admin' ]"}
{"severity":"DEBUG","message":"[ 'value', 'catgrillo' ]"}
{"severity":"DEBUG","message":"[ 'field', 'content' ]"}
{"severity":"DEBUG","message":"[\n  'value',\n  'Committed members of a community are more likely to provide meaningful content that other users value. Additionally,  commitment is an important building block for behavior regulation. Certain types of commitment can occur in online communities, the type of commitment you want will differ depending on your vision for the community. '\n]"}
{"severity":"DEBUG","message":"[ 'field', 'createdAt' ]"}
{"severity":"DEBUG","message":"[ 'value', 1600478869565 ]"}
{"severity":"DEBUG","message":"[ 'field', 'nodeType' ]"}
{"severity":"DEBUG","message":"[ 'value', 'Concept' ]"}
{"severity":"DEBUG","message":"[ 'field', 'tags' ]"}
{"severity":"DEBUG","message":"[\n  'value',\n  [\n    {\n      node: 'nL5vJd6vfnRC5s9uGeRU',\n      title: 'CSCW (Computer-supported cooperative work)'\n    }\n  ]\n]"}
smomin commented 3 years ago

ok, so you created the key, but you did not specify the index. I have updated your API key to give access to the nodeindex.

ImanYZ commented 3 years ago

I ran the script again. I'm getting the exact same error message and all the logs.

smomin commented 3 years ago

I need access to your Algolia account. Please go https://www.algolia.com/account/support and give me read access so I can check the settings.

smomin commented 3 years ago

Were you able to figure out the issue? Can I close this ticket?

ImanYZ commented 3 years ago

Yes, it's fixed. Thank you.

smomin commented 3 years ago

Hey @ImanYZ, can you post your solution that fixed this issue

ImanYZ commented 3 years ago

I just ignored that error message and let the script complete its execution. It seems working because it generated the records on my Algolia index.