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 Furkan KAMACI <fu...@gmail.com> on 2013/11/20 16:44:00 UTC

Solr Highlighting Response Type

Here is an example from wiki:

Iterator<SolrDocument> iter = queryResponse.getResults().iterator();

    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> highlightSnippets =
queryResponse.getHighlighting().get(id).get("content");
      }
    }

Why  queryResponse.getHighlighting().get(id).get("content"); returns a
List? Is it because of multivalued things or any other purposes?

Also is there is a control as like that:

 if (queryResponse.getHighlighting().get(id) != null)

Can we configure Solr returning highlights *at same order *of response
document list and can we include  all response documents at highlight list
even there is not a highlighted match of its fields. Because I want to get
the first response and if there is a highlighted field at highlighting list
I want to use highlighted match if not I want to use plain version. I know
that I can use *id * field of response document to get highlighted fields
of it but my ids are randomized and I can not use it.