lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Green <>
Subject Highlighting question
Date Tue, 04 Aug 2009 00:05:36 GMT
Hi, folks.  I'm trying to get a very simple example working with Solr
highlighting.  I have a default search field (called, unsurprisingly
"default-search-field") with text in it and I want query terms to be
highlighted in that field when I do a search.

I'm using an up to date (as of this evening) checkout of 1.4.  My
solrconfig.xml contains the following highlighting element:

   <!-- Configure the standard fragmenter -->
   <!-- This could most likely be commented out in the "default" case -->
        <fragmenter name="gap"
class="org.apache.solr.highlight.GapFragmenter" default="true">
            <lst name="defaults">
                <int name="hl.fragsize">200</int>

   <!-- A regular-expression-based fragmenter (f.i., for sentence
extraction) -->
        <fragmenter name="regex"
            <lst name="defaults">
      <!-- slightly smaller fragsizes work better because of slop -->
                <int name="hl.fragsize">170</int>
      <!-- allow 50% slop on fragment sizes -->
                <float name="hl.regex.slop">0.5</float>
      <!-- a basic sentence pattern -->
                <str name="hl.regex.pattern">[-\w ,/\n\"']{20,200}</str>

   <!-- Configure the standard formatter -->
        <formatter name="html"
class="org.apache.solr.highlight.HtmlFormatter" default="true">
            <lst name="defaults">
                <str name="hl.simple.pre"><![CDATA[<span class="ht">]]>
                <str name=""><![CDATA[</span>]]>

I'm using SolrJ to talk to the Solr server.  Here's the code to do a
query, where qs is the query string.

            SolrQuery q = new SolrQuery(qs);
            q.set("hl.formatter", "html");
            q.set("hl.fragmenter", "regex");
            q.setFields("default-search-field", "key");
            QueryResponse resp = solr.query(q);

I've set up the dismax handler in solrconfig.xml to search the

The Solr server logs the following request for this:

INFO: [] webapp=/solr path=/select
hits=953 status=0 QTime=39

which looks about right to me, but I don't see any highlighting in the results.

I'm clearly missing something pretty fundamental here, and any help
would be appreciated.

Steve Green

View raw message