lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jay Hill <jayallenh...@gmail.com>
Subject Re: Highlighting in SolrJ?
Date Fri, 11 Sep 2009 16:53:54 GMT
Try adding this param: &hl.fragsize=30000
(obviously set the fragsize to whatever very high number you need for your
largest doc.)

-Jay


On Fri, Sep 11, 2009 at 7:54 AM, Paul Tomblin <ptomblin@xcski.com> wrote:

> What I want is the whole text of that field with every instance of the
> search term high lighted, even if the search term only occurs in the
> first line of a 300 page field.  I'm not sure if mergeContinuous will
> do that, or if it will miss everything after the last line that
> contains the search term.
>
> On Fri, Sep 11, 2009 at 10:42 AM, Jay Hill <jayallenhill@gmail.com> wrote:
> > It's really just a matter of what you're intentions are. There are an
> awful
> > lot of highlighting params and so highlighting is very flexible and
> > customizable. Regarding snippets, as an example Google presents two
> snippets
> > in results, which is fairly common. I'd recommend doing a lot of
> > experimenting by changing the params on the query string to get what you
> > want, and then setting them up in SolrJ. The example I sent was intended
> to
> > be a generic starting point and mostly just to show how to set
> highlighting
> > params and how to get back a List of highlighting results.
> >
> > -Jay
> > http://www.lucidimagination.com
> >
> >
> > On Thu, Sep 10, 2009 at 5:40 PM, Paul Tomblin <ptomblin@xcski.com>
> wrote:
> >
> >> If I set snippets to 99999 and "mergeContinuous" to true, will I get
> >> the entire contents of the field with all the search terms replaced?
> >> I don't see what good it would be just getting one line out of the
> >> whole field as a snippet.
> >>
> >> On Thu, Sep 10, 2009 at 7:45 PM, Jay Hill <jayallenhill@gmail.com>
> wrote:
> >> > Set up the query like this to highlight a field named "content":
> >> >
> >> >    SolrQuery query = new SolrQuery();
> >> >    query.setQuery("foo");
> >> >
> >> >    query.setHighlight(true).setHighlightSnippets(1); //set other
> params
> >> as
> >> > needed
> >> >    query.setParam("hl.fl", "content");
> >> >
> >> >    QueryResponse queryResponse =getSolrServer().query(query);
> >> >
> >> > Then to get back the highlight results you need something like this:
> >> >
> >> >    Iterator<SolrDocument> iter = queryResponse.getResults();
> >> >
> >> >    while (iter.hasNext()) {
> >> >      SolrDocument resultDoc = iter.next();
> >> >
> >> >      String content = (String) resultDoc.getFieldValue("content"));
> >> >      String id = (String) resultDoc.getFieldValue("id"); //id is the
> >> > uniqueKey field
> >> >
> >> >      if (queryResponse.getHighlighting().get(id) != null) {
> >> >        List<String> highightSnippets =
> >> > queryResponse.getHighlighting().get(id).get("content");
> >> >      }
> >> >    }
> >> >
> >> > Hope that gets you what you need.
> >> >
> >> > -Jay
> >> > http://www.lucidimagination.com
> >> >
> >> > On Thu, Sep 10, 2009 at 3:19 PM, Paul Tomblin <ptomblin@xcski.com>
> >> wrote:
> >> >
> >> >> Can somebody point me to some sample code for using highlighting in
> >> >> SolrJ?  I understand the highlighted versions of the field comes in
a
> >> >> separate NamedList?  How does that work?
> >> >>
> >> >> --
> >> >> http://www.linkedin.com/in/paultomblin
> >> >>
> >> >
> >>
> >>
> >>
> >> --
> >> http://www.linkedin.com/in/paultomblin
> >>
> >
>
>
>
> --
> http://www.linkedin.com/in/paultomblin
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message