Summarizing html content in search results

Hello team,

We have created an instance of Elasticsearch and have created an index configuration that will return the fields we need on search.
However, one feature we want is a summary of the html content so we can display it along with each search result.

The summary should highlight the query the user searched for.
I have seen that there is something called meta_description which seems to be what we want, however, our html pages do not have the <meta name="description"> tag Elasticsearch is looking for to populate this field.

Is there any other way we can get a summary? maybe we are missing some sort of other configuration?

Thank you!

Thanks for reaching out, @Hiru_Fernando. I'm interested in learning some more context about the summary you are looking for. What does the output look like? Also what version of Elasticsearch are you using?

Hi Jess!
So actually I was able to use the following to get snippets of HTML body content.

          body_content: {
            raw: {},
            snippet: {
              size: 100,
              fallback: true,
            },
          },

with this I can get back snippets that are found within the content/body content that basically highlights the query I searched for.

1 Like

Oh awesome, @Hiru_Fernando! Thanks for sharing your solution!