lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Bende <bbe...@gmail.com>
Subject Re: SolrJ getHighlighting() does not return results in order
Date Wed, 22 Mar 2017 21:17:44 GMT
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
<leoperezpulido@hotmail.com> 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.

Mime
View raw message