Solr highlighting for external fields

254 views Asked by At

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

There are 2 answers

0
nak On

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
susmit shukla On

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.