Skip to main content

Posts

Showing posts with the label indexing

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.

Lucene Highlighter for snippet generation for search with solr

Here is a post which talks about the same and shows that there is such functionality available with lucene contrib itself and you may not need to build it on your own: http://hrycan.com/2009/10/25/lucene-highlighter-howto/ It says that there is this contrib called lucene-highlighter-2.4.1.jar for generating the fragments or snippets for search results by using the term frequencies calculated while indexing. The Contrib and other examples can be downloaded from the link  http://code.google.com/p/hrycan-blog/  by the same author