CakeFest 2024: The Official CakePHP Conference

yaz_sort

(PHP 4 >= 4.0.7, PECL yaz >= 0.9.0)

yaz_sortソート条件を設定する

説明

yaz_sort(resource $id, string $criteria): void

この関数は、ソート条件を設定して Z39.50 Sort を有効にします。

この関数は、yaz_search()前に コールします。この関数を単独で使用しても何も意味はありません。 yaz_search() と組み合わせて使用した場合、 検索応答が受信されてから全ての Z39.50 Present で取得される前に Z39.50 Sort が送信されます。

パラメータ

id

yaz_connect() が返す接続リソース。

criteria

field1 flags1 field2 flags2 のような 形式の文字列。field1 は最初にソートする属性を、そして field2 は 2 番目の属性を… のように指定します。

フィールドは、カンマで区切られた 型 = 値 の組からなる数値属性の 組み合わせ(例 1=4,2=1)、または 文字列の方法を指定することも可能です(例 title)。 フラグは次の文字の並びからなり、空白により区切ることはありません。

ソートフラグ
a

昇順ソート

d

降順ソート

i

大文字小文字を区別しないソート

s

大文字小文字を区別するソート

戻り値

値を返しません。

例1 ソート条件

Bib1 属性のタイトル(title)で大文字小文字を区別しない昇順のソートを 行うには、以下のソート方法を使用してください。

1=4 ia

2 番目のソート条件として著者(author)を指定し、大文字小文字を区別する 昇順のソートを行うには以下のようにします。

1=4 ia 1=1003 sa

add a note

User Contributed Notes 1 note

up
1
peter at NOSPAMimtc dot gatech dot edu
19 years ago
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.
To Top