Class: Ferret::Search::SortField
- Inherits:
-
Object
- Object
- Ferret::Search::SortField
- Defined in:
- ext/r_search.c
Overview
Summary
A SortField is used to sort the result-set of a search be the contents of a field. The following types of sort_field are available;
-
:auto
-
:integer
-
:float
-
:string
-
:byte
-
:doc_id
-
:score
The type of the SortField is set by passing it as a parameter to the constructor. The :auto
type specifies that the SortField should detect the sort type by looking at the data in the field. This is the default :type value although it is recommended that you explicitly specify the fields type.
Example
title_sf = SortField.new(:title, :type => :string)
= SortField.new(:rating, :type => float, :reverse => true)
Note 1: Care should be taken when using the :auto sort-type since numbers will occur before other strings in the index so if you are sorting a field with both numbers and strings (like a title field which might have “24” and “Prison Break”) then the sort_field will think it is sorting integers when it really should be sorting strings.
Note 2: When sorting by integer, integers are only 4 bytes so anything larger will cause strange sorting behaviour.