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 <jayallenh...@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 <ptomb...@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

Reply via email to