(PHP 4 >= 4.0.7, PECL yaz >= 0.9.0)
yaz_sort — Sets sorting criteria
$id
, string $criteria
)This function sets sorting criteria and enables Z39.50 Sort.
Call this function before yaz_search(). Using this function alone does not have any effect. When used in conjunction with yaz_search(), a Z39.50 Sort will be sent after a search response has been received and before any records are retrieved with Z39.50 Present ( yaz_present().
id
The connection resource returned by yaz_connect().
criteria
A string that takes the form field1 flags1 field2 flags2 where field1 specifies the primary attributes for sort, field2 seconds, etc..
The field specifies either a numerical attribute combinations consisting of type=value pairs separated by comma (e.g. 1=4,2=1) ; or the field may specify a plain string criteria (e.g. title. The flags is a sequence of the following characters which may not be separated by any white space.
Sort ascending
Sort descending
Case insensitive sorting
Case sensitive sorting
没有返回值。
Example #1 Sort Criterias
To sort on Bib1 attribute title, case insensitive, and ascending you would use the following sort criteria:
1=4 ia
If the secondary sorting criteria should be author, case sensitive and ascending you would use:
1=4 ia 1=1003 sa
peter at NOSPAMimtc dot gatech dot edu (2004-08-26 08:37:47)
This information is located in several places in the documentation, but takes awhile to find.
yaz_sort() only works for fields that have an associated sort register. Failure to link a sort register will generate the error "Cannot sort according to sequence".
The sort register is created in the default.idx file and referenced in the *.abs file. This is the sort register setting in default.idx:
...
# Sort register (no mapping at all)
sort s
completeness 1
charmap string.chr
...
In the above code the "s" register is setup as the sort register. Charmap string.chr defines the string conversion for diacritics.
This is the reference to the sort index in the *abs file:
...
elm (2,1) title !:w,!:p,!:s
...
In the above line the "!:s" causes a sort register to be created for the field.
Once the above changes have been made, reindex all the source records and restart the server. Check for a "sort<fieldid>-0.mf" file in the zebra data directory to verify operation. yaz_sort() should now work properly.