In certain situations, the standard highlighting mechanism may not be performing as well as you would like it to be. For example, you may have long text fields and you want the highlighting mechanism to work with them. This recipe will show you how to do that.
We begin the index structure configuration which looks as follows (just add this to your
schema.xml
file, to thefield
section):<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="name" type="text" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
The next step is to index the data. We will use the test data which looks like the following code:
<add> <doc> <field name="id">1</field> <field name="name">Solr Cookbook first edition</field> </doc> <doc> <field name="id">2</field> <field name="name">...