Efficient highlighting
In certain situations, the standard highlighting mechanism might not be performing as you would like it to be. For example, you might have long text fields and want the highlighting mechanism to work with them. In such cases, there is a need of another, more efficient highlighter. Thankfully, there is a highlighter that is very efficient, and this recipe will show you how to use it.
How to do it...
We begin with the index structure configuration, which looks as follows (just add the following section to your
schema.xml
file):<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="name" type="text_general" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
The next step is to index the data. We will use the following test data for the purpose of this recipe:
<add> <doc> <field name="id">1</field> <field name="name">Solr Cookbook first edition</field...