I need to create a search in a HTML field using Elasticsearch. I have a react app (Next.js to be precise) to display the results. Since the highlighted results are HTML code, I want to use dangerouslySetInnerHTML
but as expected it breaks the rendering of the page since the highlights are just fragments of HTML and some tags might not be closed so it interferes with the page's HTML. So the question is if there is some configuration to let Elasticsearch to search within the tags? I know that there is an approach to store just text in the index with HTML stripped but I need to use highlighted data to allow users to click on one of the search result and they would be redirected to the related page and be scrolled to that highlighted fragment within the page. Any advice would be appreciated.
Asked
Active
Viewed 62 times
0

orlyohreally
- 410
- 6
- 19