Intergrate with results from external API

Hi, the current proof of concept serach on our site pulls in results from within wordpress and from an external api.
I have shotcodes writen in php that return an array of objects which has title, extract, relevance score etc…
In the themes overriden search.php I edit the have_posts loop to integrate the wordpress results with the external results using relevance - choosing a different template for the results html depending what type it is.

Is there any way to similarly integrate external results into algolia serach?

Hi @joe.lambert

If I understand correctly, you’re describing what Algolia does ! My advice would be to :

And that should be it. My point is that you can enrich your index with any source of data you want, Algolia will manage the search within and you won’t have to handle custom code for search.

This suppose your API data have the same structure than the WP content but sounds manageable anyway.

If I don’t answer your question, could you be a little more specific in describing what you’re trying to achieve ?

Thanks :wink:

Thanks Pierre, I’ve been working on understanding how algolia works a bit better, I think I will try to get the “external” from word press results into json format and add them to the search index rather than add them to algolia results after the fact.

The only problem I have then is that the algolia index will need to be updated with daily json updates from the external site.
Unless when you say “connect your api to the algola’s index” you mean I can give the index an api rather than directly uploading a json file? (I’ve had to write my own modified json file based on the external apis response)

Cheers :slight_smile:

Hey @joe.lambert

You can not directly connect an API to Algolia indices but if you ask me, all API should return JSON so that should not be a problem.

To answer you, you’ll have to deploy an update strategy to sync data when needed :wink:

There is also a lot of topics about update on this very forum.

Feel free if you have more questions !