Back

[Solved]Appwrite Database not Synchronising with Algolia

  • 0
  • Databases
  • Functions
Meldiron
21 Dec, 2023, 09:03

Just use original source code, without any changes. Orignal can be found here: https://github.com/appwrite/templates/tree/main/node/sync-with-algolia

TL;DR
Appwrite Database was not synchronizing with Algolia, but the issue has been solved. The solution involved modifying the template code in `index.html` to display the desired data. The user can edit the code in the Appwrite console to configure the attributes to be displayed. The template can be customized further as per the user's requirements. The default template syncs the entire document, but irrelevant attributes can be configured in the Algolia dashboard. Best practice is to only take the ID from Algolia search results and use it to retrieve the document from Appwrite for up-to-date information. To fix the format issue, the user can update
Emilson
21 Dec, 2023, 09:04

So how do i connect this to my function ?

Emilson
21 Dec, 2023, 09:04

Not sure what you mean

Meldiron
21 Dec, 2023, 09:05

You change code in your repository that you shared with me. By pushing to your repo, function is automatically deployed

Emilson
21 Dec, 2023, 09:07

Oh, you mean i should update my codebase with the original source code which is the one you pasted here?

Emilson
21 Dec, 2023, 09:07

Is that what you meant ?

Meldiron
21 Dec, 2023, 09:07

Yes. That way you dont use any IDs in the code. Instead, it will read from process.env, which should fix the problem

Emilson
21 Dec, 2023, 09:08

So which of the files will i update ?

Emilson
21 Dec, 2023, 09:09

I already cleared the IDS added to the main.js file, so it's reading from the process.env

Meldiron
21 Dec, 2023, 09:13

Does the execution work now?

Emilson
21 Dec, 2023, 09:24
Emilson
21 Dec, 2023, 09:25

I think so

Emilson
21 Dec, 2023, 09:25

Let me check if the document is indexed on algolia

Meldiron
21 Dec, 2023, 09:25

πŸŽ‰

Emilson
21 Dec, 2023, 09:26

How do i fix this format ?

Emilson
21 Dec, 2023, 09:26
Meldiron
21 Dec, 2023, 09:28

By default, template sync the whole document. As far as I understand, that's okay to do in Algolia. Inside Algolia dashboard you can configure which attributes are irrelevant, or which have higher priority.

Then, after you recieve results from Algolia after search, best practice is to only take ID, and using ID, search for the document in Appwrite. This way you have always up-to-date state of the document

Meldiron
21 Dec, 2023, 09:28

If you only want to sync some information, you can rewrite the source code of the function to only sync parameters you need. Template is only meant as a starting point, you can customize it as much as you want.

Emilson
21 Dec, 2023, 09:40

Oh, okay. Must the template display the data as a JSON file?

Meldiron
21 Dec, 2023, 09:44

Functions are fully customizable, and it's up to your imagination to change the template. All functions follow HTTP standard, so you can do anything you could do with any other HTTP server such as Express, Django or Laravel.

Emilson
22 Dec, 2023, 11:45

@Meldiron Can you guide me on how I can edit this to show only the details i want through Appwrite console, i configured my attributes on Algolia, but that of Appwrite i couldn't and my private data is still displaying.

Emilson
22 Dec, 2023, 11:48

This is how it's displaying on my Algolia index, i want it to be displayed this way on the Demo

Meldiron
22 Dec, 2023, 12:41

You can hop into index.html in the function, and change the way data is displayed in the demo. There is small JS code for it

Emilson
22 Dec, 2023, 15:45

I have fixed it, thanks.

Emilson
22 Dec, 2023, 16:21

[Solved]Appwrite Database not Synchronising with Algolia

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more