Top Menu

Custom Search

Thursday, July 26, 2012

How to generate snippets in solr?


Snippet generation in the solr with lucene highlight is simple to configure task. Now with the advanced versions of he solr the snippet geneation works just fine bedefault. But there is need for change in the request.
To get the search results highlighted with the search terms in them and also to get the snippets i.e relevant text parts for users for deciding the relevance of the specific search results, you have to query the solr with parameters hl and hl.fl set to 'true' and 'filed name like title/content' etc.
Ex. Your query for the locally setup solr will be
http://localhost:8983/solr/select/?q=learning%20management%20systems&version=2.2&start=0&rows=10&indent=on&hl=true&hl.fl=CONTENT
where CONTENT is my name of my field which may be different for others.

And the highlighted part of the results occure at the botton after the results tag, as .
And in that the search terms are enclosed in the tags.

No comments: