How to index codeblocks in react-instantsearch?

I am trying to figure out how to to index codeblock in < pre > and < code > tags with React-Instantsearch. I had not luck with the docs.

React InstantSearch is a library that aims at building search UIs, not indexing content. You might need to have a look at the JavaScript API Client and its indexing capabilities.

Thanks for clarifying. Both links you provided do not answer my question.
Our users have to be able to search for code inside codeblocks that are surrounded by < code > tags.

Algolia does not do that with the implementation we have in place. The docs do not offer an explanation I could find to help me solve this issue. I need to find a way to let Algolia know to also let users search content within html < code > blocks.

Hi @christina.hastenrath - Following up here in case it benefits other users.

At first, I was going to suggest looking at our DocSearch offering (https://community.algolia.com/docsearch/) but I imagine you’ve already seen that and, indeed, it does not include large body text or code blocks in the searchable attributes.

For example, if your Markdown looked like:

var s = "JavaScript syntax highlighting";
alert(s);

Algolia would not handle translating that into a record that looks like:

{
   "name": "my record",
   "url": "myurl.com",
   "body": "var s = "JavaScript syntax highlighting ;alert(s);"
}

We would rely on you to determine at indexing time how to recognize and handle any Markdown that you would want indexed to Algolia in the form of an attribute. We are schemaless and accept any key-value JSON pair, but how it gets to that form is up to you!

I hope this clarifies what Algolia can take care of, and what will need to be handled in advance.

Thank you so much, this has helped greatly.

1 Like