lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: Sorting in Solr
Date Thu, 03 May 2007 21:45:43 GMT

: Just to be clear, I have multiple fields per document that Are coming
: back in the queried XML. Let's say it's name, id, date, description.  I
: want to sort dynamically on fields but for my test case on Description.
: Are you suggesting that there be one field defined per document, or you
: can only sort on one field per request?  I'm not sure I understand this
: explanation.

if you want to sort on a field called "description" then there must be at
most one indexed term per document for that field.  if you also ant to
sort on a field called "date" there must also be at most one indexed value
for that field per document.  for numeric or date type fields, ensuring
that there is only one index value per document is a simple value of
making sure the field is defined as "multiValue="false" in your schema,
but for textish fields it's not as simple ... you may send only one
<field...>...</field> per doc for that field name but if you are using a
non trivial analyzer you'll wind up with more then one indexed term.

so you define name and description to be whatever you type you want with
whatever analyzer you want, and then you use copyField to create a second
version of each called nameSort and descriptionSort which use the StrField
filedtype ... now you can sort on either of those, or both at the same
time (ie: "nameSort asc, descriptionSort desc")

: Chris Hostetter wrote:
: > : having issues with it.  Some fields work some do not and my results seem
: > : to suggest that it doesn't work when there are any non-alphaNumeric
: > : values in the fields.  Can someone out there either confirm this or let
: > : me know what I may be doing wrong?  is it a matter of using a different
: > : analyzer setting or filter factory than the default setting for text.
: >
: > Sorting requires that there be a single Term/Token per doc ... most
: > Analyzers do not have this behavior, so you need to use copyField to
: > create a String version of the field that you use for sorting.
: >
: > the example schema in the trunk shows this using the name and nameSort
: > fields ... in the 1.1 release there is a comment about the manu_exact
: > field.
: >
: > I've added this as a FAQ.
: >
: >
: >
: > -Hoss
: >
: >
: >


View raw message