Hello,
Yes, getHightlighting() returns a Map<String, Map<String, List<String>>>, so I first get the map = response.getHightlighting(); Then I initialize a TreeMap with the map object just obtained above (new TreeMap<>(map)). I then get a collection-view of this treeMap object, like: set = treeMap.entrySet(); To obtain the order that corresponds with the order returned from a SolrDocumentList I initialized an ArrayList dynamically, as in: ArrayList<String> highlightResults = new ArrayList<>(); for(Map.Entry<String, Map<String, List<String>>> me : set) { highlightResults.add(me.getValue().get("content").get(0)); } And with that I obtained the desired results. Thanks for your help. Leonardo. ________________________________ From: Bryan Bende [via Lucene] <ml-node+s472066n4326379...@n3.nabble.com> Sent: 22 March 2017 17:44:18 To: leoperezpulido Subject: Re: SolrJ getHighlighting() does not return results in order Hello, I believe getHighlighting() returns Map<String (docid), Map<String (fieldName), List<String (snippets)>>> . Generally Maps are not expected to iterate in order unless you know the underlying implementation of the Map, for example LinkedHashMap will iterate in the insertion order and HashMap will not. You should be able to take the doc id from one of the results in the document list and then do getHighlighting().get(docid) to get the Map<String (fieldName), List<String (snippets)>> for the given document. Hope that helps. -Bryan On Wed, Mar 22, 2017 at 8:54 AM, leoperezpulido <[hidden email]</user/SendEmail.jtp?type=node&node=4326379&i=0>> wrote: > Hi, > > Implementing highlighting with *SolrJ* does not return results in the proper > order while I "page" through results. This not seems to be a problem with > the RESTful API. > > // ... > query.setQuery("text"); > /* > The problem is when I set start to get different "pages", > the results returned by getHighlighting() are disordered. > */ > query.setStart(0); > query.setSort("score", SolrQuery.ORDER.desc); > query.setIncludeScore(true); > > query.setHighlight(true); > query.addHightlightField("content"); > // ... > > Take the example of a simple index with a field named content and field's > values like: > Document 1 > Document 2 > Document 3 > etc. > > With the results returned by SolrDocumentList and with the RESTful API, I > can paginate in the normal way, and the results remain ordered. This is not > the case when I get results from getHighlighting(). > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/SolrJ-getHighlighting-does-not-return-results-in-order-tp4326218.html > Sent from the Solr - User mailing list archive at Nabble.com. ________________________________ If you reply to this email, your message will be added to the discussion below: http://lucene.472066.n3.nabble.com/SolrJ-getHighlighting-does-not-return-results-in-order-tp4326218p4326379.html To unsubscribe from SolrJ getHighlighting() does not return results in order, click here<http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4326218&code=bGVvcGVyZXpwdWxpZG9AaG90bWFpbC5jb218NDMyNjIxOHwzNjU4MjUxMTY=>. NAML<http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> -- View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-getHighlighting-does-not-return-results-in-order-tp4326218p4326388.html Sent from the Solr - User mailing list archive at Nabble.com.