0
votes

I would like to use Solr highlighting, but our documents are only indexed and not stored. The field values are found in a separate database. Is there a way to pass in the text to be highlighted without Solr needing to pull that text from its own stored fields? Or is there an interface that would allow me to pass in a query, a field name, a field value and get back snippets?

I'm on Solr 5.1.

2
Sorry, but you need to store the field if you want to use the highlighting feature. If you need to retrieve and display the highlighted snippets then the fields definitely needs to be stored. When you say your fields are being stored in a separate database, do you mean you have dynamic fields?Nathan Hall
The documents are stored in MongoDB. Only the IDs are returned from Solr and the documents are retrieved from MongoDB. We do this for search performance and because our documents have a more complex structure than what is indexed in Solr.Charles

2 Answers

1
votes

Lucene supports highlighting (returns offsets) also for non-stored content by using docValues.

Enabling a field for docValues only requires adding docValues="true" to the field (or field type) definition, e.g.:
<field name="manu_exact" type="string" indexed="true" stored="false" docValues="true" />

(introduced in Lucene 8.5, SOLR-14194)

0
votes

You could reindex the resultset (read from database) in an embedded solr instance and run the query with same set of keywords with highlighting turned on and get the highlighted text back.
You could read the schema and solrconfig as resources from local jar and extract to temporary solr core directory to get this setup working.