Harinder
Harinder

Reputation: 343

Can Solr provide a summary per document with highlighting?

I'm very new to Solr so this might be a stupid question.

The requirement is that a query should return results with (intelligent) summary containing highlighted words which match the query text. From what I have read, the highlighted text will be effectively be the document summary. I managed to get highlighting working, however, Solr doesn't provide highlighting for some documents. So my thought process was that if there is a document for which Solr can't provide highlighted text (aka summary), I will ask Solr for: a) general document summary (regardless of what the search term is), or b) top n terms

But I haven't been able to make progress on either of the two items.

The underlying questions is why is Solr not generating highlighted summary for certain documents? I know for a fact that the documents contain the term I'm searching for.

Any insights into this will be much appreciated. Thank you.

Edit1:

Query: /select/?q=agents&start=0&fl=full_path,author,title,content-type,score&hl=true&hl.snippets=5.

The document is a PDF document, the word 'agents' occurs once. Here is the text snippet from the PDF which contains the word. "The Omega 3 & 6 fatty acids (eicosapentaenoic acid) and DHA (docasahexaenoic acid) are constituents of fish oils that act as anti-inflammatory agents. (Usually, these products are sold separately in health food stores as salmon oil or under other names.)"

Edit 2:

The default field (df) is set to be text in solrconfig.xml. I copy all the fields into a field called text which is defined as text_general. Looking at the text_general field type, the only tokenizer specified is solr.StandardTokenizerFactory. I should reiterate here that highlighting does work, the issue is that it doesn't work on some documents. Edit 1 contains information on the document text which I believe should be highlighted with the given query.

Upvotes: 1

Views: 1808

Answers (2)

ishayle
ishayle

Reputation: 365

The Unified Highlighter presents such option, you can pass hl.defaultSummary=true

Upvotes: 0

Arun
Arun

Reputation: 1787

Make sure all your fields that you expected to have text highlighted have stored="true". Solr can highlight, it needs access to the original text, to access the original text for a field, it needs to be "stored". So your field that is holding mentioned text above needs to be verified. Exmaple: .

Upvotes: -1

Related Questions