Subject: | Patch to allow specification of sort algorithm |
The attached patch gives users of the modules the opportunity to specify
the sorting algorithm as an option to the search() method.
Also included is some extra documentation on search options and a small
fix to the SOAP::ISIWoK::Lite pod which will hopefully fix the borken
pod display on search.cpan.org
You may apply the patch like this:
~/SOAP-ISIWoK-1.02> patch -p0 -i sort.patch
Subject: | sort.patch |
--- lib/SOAP/ISIWoK.pm.orig 2010-09-23 15:55:13.000000000 +0200
+++ lib/SOAP/ISIWoK.pm 2010-12-09 18:51:21.000000000 +0100
@@ -319,6 +319,7 @@
my $max = exists $opts{max} ? $opts{max} : 10;
my $database = exists $opts{database} ? $opts{database} : "WOS";
my $fields = exists $opts{fields} ? $opts{fields} : [qw( times_cited )];
+ my $sort = ( exists $opts{'sort'} and $opts{'sort'} =~ /\A(?:Date|Relevance|Times Cited)\Z/o ) ? $opts{'sort'} : "Relevance";
my $soap = $self->_soap();
@@ -330,8 +331,8 @@
SOAP::Data->name("depth")->value(""),
# editions is SCI, SSCI etc.
SOAP::Data->name("editions")->value(""),
- # sort by descending relevance
- SOAP::Data->name("sort")->value("Relevance"),
+ # sort algorithm; default is by descending relevance
+ SOAP::Data->name("sort")->value("$sort"),
# start returning records at 1
SOAP::Data->name("firstRec")->value("$offset"),
# return upto 10 records
@@ -432,6 +433,37 @@
UT ISI UT identifier
ZP Zip/Postal Code
+=head2 Search Options
+
+=over 4
+
+=item offset
+
+The index of the first hit in the result set to return. Defaults to 1.
+This is mapped to the WoS API param C<firstRec>.
+
+=item max
+
+The maximum number of hits to return. Defaults to 10.
+This is mapped to the WoS API param C<numRecs>.
+
+=item database
+
+The database to search in. Defaults to "WOS".
+This is mapped to the WoS API param C<databaseID>.
+
+=item fields
+
+An array ref with the list of fields to return. An empty value means "all".
+This is mapped to the WoS API param C<fields>.
+
+=item sort
+
+Specifies the sort algorithm to use. Can be one of C<Date>, C<Relevance>, or
+C<Times Cited>. Defaults to C<Relevance>.
+
+=back
+
=head2 EXPORT
None by default.
--- lib/SOAP/ISIWoK/Lite.pm.orig 2010-09-23 15:57:49.000000000 +0200
+++ lib/SOAP/ISIWoK/Lite.pm 2010-12-09 18:50:10.000000000 +0100
@@ -69,13 +69,14 @@
my $max = exists $opts{max} ? $opts{max} : 10;
my $database = exists $opts{database} ? $opts{database} : "WOS";
my $fields = exists $opts{fields} ? $opts{fields} : [qw( times_cited )];
+ my $sort = ( exists $opts{'sort'} and $opts{'sort'} =~ /\A(?:Date|Relevance|Times Cited)\Z/o ) ? $opts{'sort'} : "Relevance";
my $doc = $self->_search_xml(
databaseID => $database,
query => $query,
depth => "",
editions => "",
- 'sort' => "Relevance",
+ 'sort' => "$sort",
firstRec => "$offset",
numRecs => "$max",
fields => "@$fields",
@@ -125,7 +126,7 @@
=head1 NAME
-SOAP::ISIWoK - search and query the ISI Web of Knowledge
+SOAP::ISIWoK::Lite - search and query the ISI Web of Knowledge
=head1 SYNOPSIS