Search code examples
solrhighlighting

Highlighting Solr search results with bin/post and managed schema


I've got Solr 6.6.1 installed. I run bin/post to fetch and index some documents into a new core. I'd like to add a text field and highlight on that field. I notice that in server/solr/myCore/conf that there is a file, managed-schema, with a warning that tells me not to edit the file.

What's the supported way to use bin/post AND enable highlighting on a text field?


Solution

  • Solr implicitly uses a ManagedIndexSchemaFactory, which is by default "mutable" and keeps schema information in a managed-schema file.

    You have several choices:

    1. Go back to <schemaFactory class="ClassicIndexSchemaFactory"/>, so you will be able to change schema file manually.

    2. Stay with managed Schema API and just modification operations via HTTP to add new field, which you will use for highlighting.

    I would recommend to stick with #2, but it's totally up to you. Official documentation will help you to choose which schema options for your text fields you need to get the best out of highlighting.