InstantSearch.js render or transformItems function

Hello Algolia users
I have difficulties to get to work InstantSearch but the Search API is working well.

I created a 2 field database with 1 field(req) for a specific search code and another field (html) with html snippets stored as json.

Using the Search API I can well retrieve the html field by searching for a specific code in field req. But adapting the example app from Instantsearch and inserting a search code nothing happens.
Maybe you can provide me a hint how to find the solution?
Thx for your advice.
Best regards, Peter

Hi @pte1601,

It’s a bit complicated to understand what’s wrong with your implementation. Could you provide an example of what you already tried? It would help to better understand the issue. We provide a template for each flavor. You just have to pick the one you’re using:


Hello Samuel
thx for your reply; meanwhile I managed to get the search results using the instantsearch.js:

Example for clarity:
in the searchable field [requirement] the users enters a search code
the result field [html ] contains the html code to be displayed, stored as json.
[html] is: <body><p class="h1" id="CS_27_0_27_25_a_">CS 27.25(a) Maximum weight</p>

Now the field html containing the html code stored as json needs to be converted to real html code and displayed;

I understand that this could be managed using the:

  • transformItems function
  • render function

The question is: which is the function to be used for this feature?

Thx for your reply

Best regards, Peter

Hi @pte1601,

You should use the templates (or the render function) for this use case, but both solutions are possible.

The transformItems option is useful to alter the results before the render e.g. sort the element, create a new attribute. You can also use it to “prepare” the data for the render function.

Hope that helps!