You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Dave Twaddell <da...@twaddell.org> on 2012/11/05 13:41:43 UTC

How to request multiple snippet lengths

Hi,

I am trying to find a way to request multiple snippets of different lengths
for a single field. I know that this could be accomplished by issuing two
separate queries or duplicating the field, but I want to avoid doubling the
query load or index size. I'd also rather not resort to writing a custom
snippet generator.

I am using Solr 4.0 and I thought perhaps the new field aliasing feature
would be an ideal solution. However it appears that the highlighting
component doesn't understand this new syntax. For instance the following
request would ideally return two highlighted snippets: a short snippet and
the full field:

http://localhost:8983/solr/select?defType=edismax&q=foo&qf=content&fl=id&hl=true&hl.fl=content,snip:content&f.content.hl.fragsize=50000&f.snip.hl.fragsize=200&wt=json&indent=true

This results in something like the following:

"highlighting":{
"12345":{
  "content":{
    "snippet":["<em>foo</em> bar baz"]},
  "snip:content":{
    "snippet":null}},

>From this I gather that the highlighter looks for the field named
"snip:content" and fails. I tried a number of variations with the field
alias specified in the fl, qf and f.myalias.qf params, but to no avail.
I've been pouring over JIRA issues, patches and source code but I can't
determine what the proper syntax should be.

Does anyone have an ideas on how to go about this?

Thanks,
  Dave


--
"Where there is love, nothing is too much trouble and there is always
time." ~ ‘Abdu’l-Bahá