You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2009/12/10 16:52:43 UTC

[Solr Wiki] Update of "Solrj" by JanBaudisch

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "Solrj" page has been changed by JanBaudisch.
The comment on this change is: Code for iterating over search results does not work..
http://wiki.apache.org/solr/Solrj?action=diff&rev1=40&rev2=41

--------------------------------------------------

  Then to get back the highlight results you need something like this:
  
  {{{
-     Iterator<SolrDocument> iter = queryResponse.getResults();
+     Iterator<SolrDocument> iter = queryResponse.getResults().iterator();
  
      while (iter.hasNext()) {
        SolrDocument resultDoc = iter.next();
  
-       String content = (String) resultDoc.getFieldValue("content"));
+       String content = (String) resultDoc.getFieldValue("content");
        String id = (String) resultDoc.getFieldValue("id"); //id is the uniqueKey field
  
        if (queryResponse.getHighlighting().get(id) != null) {