lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley" <>
Subject Re: Order of fields returned by Document.getFields()
Date Wed, 17 Dec 2008 15:07:06 GMT
Lucene guarantees the order of all stored fields returned.
Solr guarantees the order of all values in a *specific* field, but not
the fields themselves.


On Tue, Dec 16, 2008 at 10:00 AM, Patrick Johnstone
<> wrote:
> I'm using Lucene via Solr and recently upgraded from an early Summer nightly
> build to the released version of Solr 1.3 (which seems to use something in
> the neighborhood of Lucene 2.3).  I'm posting this here because I believe
> that my issue is with Lucene, not Solr.
> After the upgrade, I noticed that the order of fields being returned for
> documents had changed.  Previously, the order of fields being returned was
> the same as the order in which they were added to the document (which is
> what's stated in the FAQ and other places I came across but not specifically
> spelled out in the Javadoc).
> Now, the fields always seem to come back in lexicographic order by field
> name.
> I believe (but am by no means sure) that this is being caused by the
> following bit of code in
>    // If we are writing vectors then we must visit
>    // fields in sorted order so they are written in
>    // sorted order.  TODO: we actually only need to
>    // sort the subset of fields that have vectors
>    // enabled; we could save [small amount of] CPU
>    // here.
>    quickSort(fields, 0, fieldCount-1);
>    for(int i=0;i<fieldCount;i++)
>      fields[i].consumer.processFields(fields[i].fields,
> fields[i].fieldCount);
> This code seems to sort the fields of the document into order before
> processing them.  If this is true, then the original field order is lost and
> can't ever be recovered.  (None of the fields in our index use TermVectors.)
> My questions are:  Is my reading of this behavior correct?  ...and...
> if so:  Is there some other way to get the original order back?
> The application that I'm building took some advantage of the fact that the
> fields were returned in the orignial order (becuase the order had some
> meaning) and it may be difficult for me to work around this change.
> Patrick Johnstone
> DejaVu Networks
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message