2
votes

I'm trying to configure / query Solr correctly (via SolrJ) to do the following:

  • Provide top hit snippets
  • Highlight the search terms in the fields

I have the snippets working correctly but I can't figure out how to get Solr to highlight the search terms in the fields. Solr highlighting suggests getting the entire field returned in the snippets and not returning any fields (to avoid duplication) but then I'd lose the snippets that are working.

Is there a way to get Solr to provide snippets (with highlighting) and also highlight the search terms in the complete field text?

1

1 Answers

2
votes

Based on various settings for Highlighting Parameters I do not believe you can do this in a single Solr query primarily because the Highlighting fragment size can only be specified once and not on a per field basis. You would need to issue two separate queries to Solr:

  1. Query 1: Highlighting options specified for your snippets &hl.fragsize=<small number>
  2. Query 2: Highlighting options specified for the complete field text &hl.fragsize=0&hl.maxAnalyzedChars=<some very large number>.

What is your use case for the need for both highlighted snippets and highlighted full text of the same field? Could this be broken up into two separate calls based on user interaction? I am guessing that you might be showing search results with the snippets and then allowing the user to view the entire text after clicking on a result...maybe?