Highlighting
You have probably heard of highlighting or seen it. You may not even know that you are actually using highlighting when you are using the bigger and smaller public search engines on the World Wide Web (WWW). When we talk about highlighting in context of full text search, we usually mean showing which words or phrases from the query were matched in the resulting documents. For example, if we use Google and search for the word lucene, we would see that word bolded in the search results:
It is even more visible on the Microsoft Bing search engine:
In this chapter, we will see how to use Elasticsearch highlighting capabilities to enhance our application with highlighted results.
Getting started with highlighting
There is no better way of showing how highlighting works other than making a query and looking at the results returned by Elasticsearch. So let's do that. We assume that we would like to highlight the terms that are matched in the title
field of our documents to increase...