|
List Info
Thread: Using yaz_present to display subsets of results
|
|
| Using yaz_present to display subsets of
results |

|
2006-11-06 02:22:15 |
Hello,
I have been unable to figure out how to use the
yaz_present() function
to return subsets of my entire result set. I couldn't find a
functional
example anywhere (inc. the PHP docs and the yaz mailing list
archives)
so was hoping someone can tell me what I'm doing wrong.
In the following example, changing the value of $start has
no effect on
the records returned by by my search:
$start = '1';
$number = '5';
$query = ' attr 1=4 test';
$id = yaz_connect('troy.lib.sfu.ca:210/innopac');
yaz_range($id, $start, $number);
yaz_syntax($id, 'marc21');
yaz_search($id, 'rpn', $query);
yaz_present($id);
yaz_wait();
// Formatting of results using XSL omitted
Number of records found: 1578
=============================
The biplane houses :poems /by Les Murray.
Embedded system design /by Peter Marwedel.
Hardening Windows systems /Roberta Bragg.
Java 2 :the complete reference /Patrick Naughton, Herbert
Schildt.
Practical MMIC design /Steve Marsh.
Since yaz_present() only takes the resource ID as a
parameter, and only
returns TRUE or FALSE, I'm not sure how else it would be
used to produce
results. The docs are sparse on this topic.
Any pointers to complete examples, or to what I am doing
wrong, would be
appreciated. I'd be happy to post my complete script when it
is working.
Mark
Mark Jordan
Head of Library Systems
W.A.C. Bennett Library, Simon Fraser University
Burnaby, British Columbia, V5A 1S6, Canada
Phone (604) 291 5753 / Fax (604) 291 3023
mjordan sfu.ca / http://www.sfu.ca/~mjorda
n/
_______________________________________________
Yazlist mailing list
Yazlist lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
|
|
| Using yaz_present to display subsets of
results |

|
2006-11-06 07:58:57 |
Mark Jordan wrote:
> Hello,
>
> I have been unable to figure out how to use the
yaz_present() function
> to return subsets of my entire result set. I couldn't
find a functional
> example anywhere (inc. the PHP docs and the yaz mailing
list archives)
> so was hoping someone can tell me what I'm doing wrong.
>
> In the following example, changing the value of $start
has no effect on
> the records returned by by my search:
>
> $start = '1';
> $number = '5';
> $query = ' attr 1=4 test';
> $id = yaz_connect('troy.lib.sfu.ca:210/innopac');
> yaz_range($id, $start, $number);
> yaz_syntax($id, 'marc21');
Use
yaz_syntax($id, "usmarc");
instead.
> yaz_search($id, 'rpn', $query);
> yaz_present($id);
It should not be necessary to use yaz_present. (yaz_search
will get the
range).
/ Adam
> yaz_wait();
>
> // Formatting of results using XSL omitted
>
>
> Number of records found: 1578
> =============================
> The biplane houses :poems /by Les Murray.
> Embedded system design /by Peter Marwedel.
> Hardening Windows systems /Roberta Bragg.
> Java 2 :the complete reference /Patrick Naughton,
Herbert Schildt.
> Practical MMIC design /Steve Marsh.
>
>
> Since yaz_present() only takes the resource ID as a
parameter, and only
> returns TRUE or FALSE, I'm not sure how else it would
be used to produce
> results. The docs are sparse on this topic.
>
> Any pointers to complete examples, or to what I am
doing wrong, would be
> appreciated. I'd be happy to post my complete script
when it is working.
>
> Mark
>
> Mark Jordan
> Head of Library Systems
> W.A.C. Bennett Library, Simon Fraser University
> Burnaby, British Columbia, V5A 1S6, Canada
> Phone (604) 291 5753 / Fax (604) 291 3023
> mjordan sfu.ca / http://www.sfu.ca/~mjorda
n/
>
> _______________________________________________
> Yazlist mailing list
> Yazlist lists.indexdata.dk
> http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
>
>
_______________________________________________
Yazlist mailing list
Yazlist lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
|
|
| Using yaz_present to display subsets of
results |

|
2006-11-06 14:40:34 |
Hi Adam,
I'm still missing something. Using yaz_syntax($id,
"usmarc") doesn't
make a difference. Here's my entire script (with record
formatting
removed -- it just prints records as XML):
<?php
$max_recs = 5;
$query = $argv[1];
$field = $argv[2];
$start_at_rec = $argv[3];
$query = trim($query);
$field = trim($field);
$fields = array('title' => '4', 'author' => '1003',
'subject' => '21');
$query = ' attr 1=' . $fields[$field] . ' ' . $query;
print "Query is $queryn";
print "Starting at record $start_at_recn";
$id = yaz_connect('troy.lib.sfu.ca:210/innopac');
yaz_range($id, $start_at_rec, $max_recs);
yaz_syntax($id, "usmarc");
yaz_search($id, 'rpn', $query);
yaz_wait();
$error = yaz_error($id);
if (!empty($error)) {
echo "Error: $error";
print "n";
exit;
} else {
$hits = yaz_hits($id);
if ($hits == '0') {
print "No hitsn";
exit;
}
}
for ($p = 1; $p <= $max_recs; $p++) {
$rec = yaz_record($id, $p, "xml; marc-8,
utf-8");
if (empty($rec)) continue;
print $rec;
}
?>
BTW I'm using PHP/YAZ version 1.0.7, YAZ version 2.1.36,
PHP 5.1.6 on
FedoraCore 5/ppc.
Mark
Adam Dickmeiss wrote:
> Mark Jordan wrote:
>> Hello,
>>
>> I have been unable to figure out how to use the
yaz_present() function
>> to return subsets of my entire result set. I
couldn't find a
>> functional example anywhere (inc. the PHP docs and
the yaz mailing
>> list archives) so was hoping someone can tell me
what I'm doing wrong.
>>
>> In the following example, changing the value of
$start has no effect
>> on the records returned by by my search:
>>
>> $start = '1';
>> $number = '5';
>> $query = ' attr 1=4 test';
>> $id = yaz_connect('troy.lib.sfu.ca:210/innopac');
>> yaz_range($id, $start, $number);
>> yaz_syntax($id, 'marc21');
>
> Use
> yaz_syntax($id, "usmarc");
> instead.
>> yaz_search($id, 'rpn', $query);
>> yaz_present($id);
> It should not be necessary to use yaz_present.
(yaz_search will get the
> range).
>
> / Adam
>
>> yaz_wait();
>>
>> // Formatting of results using XSL omitted
>>
>>
>> Number of records found: 1578
>> =============================
>> The biplane houses :poems /by Les Murray.
>> Embedded system design /by Peter Marwedel.
>> Hardening Windows systems /Roberta Bragg.
>> Java 2 :the complete reference /Patrick Naughton,
Herbert Schildt.
>> Practical MMIC design /Steve Marsh.
>>
>>
>> Since yaz_present() only takes the resource ID as a
parameter, and
>> only returns TRUE or FALSE, I'm not sure how else
it would be used to
>> produce results. The docs are sparse on this topic.
>>
>> Any pointers to complete examples, or to what I am
doing wrong, would
>> be appreciated. I'd be happy to post my complete
script when it is
>> working.
>>
>> Mark
>>
>> Mark Jordan
>> Head of Library Systems
>> W.A.C. Bennett Library, Simon Fraser University
>> Burnaby, British Columbia, V5A 1S6, Canada
>> Phone (604) 291 5753 / Fax (604) 291 3023
>> mjordan sfu.ca / http://www.sfu.ca/~mjorda
n/
>>
_______________________________________________
Yazlist mailing list
Yazlist lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
|
|
| Using yaz_present to display subsets of
results |

|
2006-11-06 19:13:30 |
Hi Mark,
FWIW, I've never been able to figure out how to make this
work on the
server side. I do it on the client side, which in terms of
your script
below would be done by substituting $start_at_rec for the
value 1 in
your final loop.
for ($p = $start_at_rec; $p <= $max_recs; $p++) {
$rec = yaz_record($id, $p, "xml; marc-8,
utf-8");
if (empty($rec)) continue;
print $rec;
}
In other words, get the whole result set, and only display
the subset of
records you're interested in.
I'm not sure whether this is good, bad, or indifferent in
terms of
utilization of resources. It doesn't appear to impose any
great wait
time on the execution of our search application, even with
large result
sets, but maybe that's attributable to our reasonably decent
server
hardware and low levels of use. I'd certainly be interested
to know if
there's a better way to do it.
John
Mark Jordan wrote:
> Hi Adam,
>
> I'm still missing something. Using yaz_syntax($id,
"usmarc") doesn't
> make a difference. Here's my entire script (with record
formatting
> removed -- it just prints records as XML):
>
> <?php
>
> $max_recs = 5;
> $query = $argv[1];
> $field = $argv[2];
> $start_at_rec = $argv[3];
> $query = trim($query);
> $field = trim($field);
>
> $fields = array('title' => '4', 'author' =>
'1003', 'subject' => '21');
>
> $query = ' attr 1=' . $fields[$field] . ' ' . $query;
> print "Query is $queryn";
> print "Starting at record $start_at_recn";
>
> $id = yaz_connect('troy.lib.sfu.ca:210/innopac');
> yaz_range($id, $start_at_rec, $max_recs);
> yaz_syntax($id, "usmarc");
> yaz_search($id, 'rpn', $query);
> yaz_wait();
>
> $error = yaz_error($id);
> if (!empty($error)) {
> echo "Error: $error";
> print "n";
> exit;
> } else {
> $hits = yaz_hits($id);
> if ($hits == '0') {
> print "No hitsn";
> exit;
> }
> }
>
> for ($p = 1; $p <= $max_recs; $p++) {
> $rec = yaz_record($id, $p, "xml; marc-8,
utf-8");
> if (empty($rec)) continue;
> print $rec;
> }
>
> ?>
>
> BTW I'm using PHP/YAZ version 1.0.7, YAZ version
2.1.36, PHP 5.1.6 on
> FedoraCore 5/ppc.
>
> Mark
>
> Adam Dickmeiss wrote:
>> Mark Jordan wrote:
>>> Hello,
>>>
>>> I have been unable to figure out how to use the
yaz_present()
>>> function to return subsets of my entire result
set. I couldn't find a
>>> functional example anywhere (inc. the PHP docs
and the yaz mailing
>>> list archives) so was hoping someone can tell
me what I'm doing wrong.
>>>
>>> In the following example, changing the value of
$start has no effect
>>> on the records returned by by my search:
>>>
>>> $start = '1';
>>> $number = '5';
>>> $query = ' attr 1=4 test';
>>> $id =
yaz_connect('troy.lib.sfu.ca:210/innopac');
>>> yaz_range($id, $start, $number);
>>> yaz_syntax($id, 'marc21');
>>
>> Use
>> yaz_syntax($id, "usmarc");
>> instead.
>>> yaz_search($id, 'rpn', $query);
>>> yaz_present($id);
>> It should not be necessary to use yaz_present.
(yaz_search will get
>> the range).
>>
>> / Adam
>>
>>> yaz_wait();
>>>
>>> // Formatting of results using XSL omitted
>>>
>>>
>>> Number of records found: 1578
>>> =============================
>>> The biplane houses :poems /by Les Murray.
>>> Embedded system design /by Peter Marwedel.
>>> Hardening Windows systems /Roberta Bragg.
>>> Java 2 :the complete reference /Patrick
Naughton, Herbert Schildt.
>>> Practical MMIC design /Steve Marsh.
>>>
>>>
>>> Since yaz_present() only takes the resource ID
as a parameter, and
>>> only returns TRUE or FALSE, I'm not sure how
else it would be used to
>>> produce results. The docs are sparse on this
topic.
>>>
>>> Any pointers to complete examples, or to what I
am doing wrong, would
>>> be appreciated. I'd be happy to post my
complete script when it is
>>> working.
>>>
>>> Mark
>>>
>>> Mark Jordan
>>> Head of Library Systems
>>> W.A.C. Bennett Library, Simon Fraser University
>>> Burnaby, British Columbia, V5A 1S6, Canada
>>> Phone (604) 291 5753 / Fax (604) 291 3023
>>> mjordan sfu.ca / http://www.sfu.ca/~mjorda
n/
>>>
>
>
> _______________________________________________
> Yazlist mailing list
> Yazlist lists.indexdata.dk
> http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
--
John Durno
Coordinator, Information Technology Services
University of Victoria Libraries
PO Box 1800 STN CSC Victoria, BC V8W 3H5
_______________________________________________
Yazlist mailing list
Yazlist lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
|
|
| Using yaz_present to display subsets of
results |

|
2006-11-06 23:38:34 |
Mark Jordan wrote:
> Hi Adam,
>
> I'm still missing something. Using yaz_syntax($id,
"usmarc") doesn't
> make a difference. Here's my entire script (with record
formatting
> removed -- it just prints records as XML):
I am confused about what you expected.. yaz_present should
send a
present request using the range given. It does not return
anything. It's
just a hint that you want a range to be returned. And these
results are
inspected using yaz_record. You don't need yaz_present in a
program - in
which case yaz_record will just fetch the record at that
point (one a time).
/ Adam
> <?php
>
> $max_recs = 5;
> $query = $argv[1];
> $field = $argv[2];
> $start_at_rec = $argv[3];
> $query = trim($query);
> $field = trim($field);
>
> $fields = array('title' => '4', 'author' =>
'1003', 'subject' => '21');
>
> $query = ' attr 1=' . $fields[$field] . ' ' . $query;
> print "Query is $queryn";
> print "Starting at record $start_at_recn";
>
> $id = yaz_connect('troy.lib.sfu.ca:210/innopac');
> yaz_range($id, $start_at_rec, $max_recs);
> yaz_syntax($id, "usmarc");
> yaz_search($id, 'rpn', $query);
> yaz_wait();
>
> $error = yaz_error($id);
> if (!empty($error)) {
> echo "Error: $error";
> print "n";
> exit;
> } else {
> $hits = yaz_hits($id);
> if ($hits == '0') {
> print "No hitsn";
> exit;
> }
> }
>
> for ($p = 1; $p <= $max_recs; $p++) {
> $rec = yaz_record($id, $p, "xml; marc-8,
utf-8");
> if (empty($rec)) continue;
> print $rec;
> }
>
> ?>
>
> BTW I'm using PHP/YAZ version 1.0.7, YAZ version
2.1.36, PHP 5.1.6 on
> FedoraCore 5/ppc.
>
> Mark
>
> Adam Dickmeiss wrote:
>> Mark Jordan wrote:
>>> Hello,
>>>
>>> I have been unable to figure out how to use the
yaz_present()
>>> function to return subsets of my entire result
set. I couldn't find a
>>> functional example anywhere (inc. the PHP docs
and the yaz mailing
>>> list archives) so was hoping someone can tell
me what I'm doing wrong.
>>>
>>> In the following example, changing the value of
$start has no effect
>>> on the records returned by by my search:
>>>
>>> $start = '1';
>>> $number = '5';
>>> $query = ' attr 1=4 test';
>>> $id =
yaz_connect('troy.lib.sfu.ca:210/innopac');
>>> yaz_range($id, $start, $number);
>>> yaz_syntax($id, 'marc21');
>>
>> Use
>> yaz_syntax($id, "usmarc");
>> instead.
>>> yaz_search($id, 'rpn', $query);
>>> yaz_present($id);
>> It should not be necessary to use yaz_present.
(yaz_search will get
>> the range).
>>
>> / Adam
>>
>>> yaz_wait();
>>>
>>> // Formatting of results using XSL omitted
>>>
>>>
>>> Number of records found: 1578
>>> =============================
>>> The biplane houses :poems /by Les Murray.
>>> Embedded system design /by Peter Marwedel.
>>> Hardening Windows systems /Roberta Bragg.
>>> Java 2 :the complete reference /Patrick
Naughton, Herbert Schildt.
>>> Practical MMIC design /Steve Marsh.
>>>
>>>
>>> Since yaz_present() only takes the resource ID
as a parameter, and
>>> only returns TRUE or FALSE, I'm not sure how
else it would be used to
>>> produce results. The docs are sparse on this
topic.
>>>
>>> Any pointers to complete examples, or to what I
am doing wrong, would
>>> be appreciated. I'd be happy to post my
complete script when it is
>>> working.
>>>
>>> Mark
>>>
>>> Mark Jordan
>>> Head of Library Systems
>>> W.A.C. Bennett Library, Simon Fraser University
>>> Burnaby, British Columbia, V5A 1S6, Canada
>>> Phone (604) 291 5753 / Fax (604) 291 3023
>>> mjordan sfu.ca / http://www.sfu.ca/~mjorda
n/
>>>
>
>
> _______________________________________________
> Yazlist mailing list
> Yazlist lists.indexdata.dk
> http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
>
> .
>
_______________________________________________
Yazlist mailing list
Yazlist lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
|
|
| Using yaz_present to display subsets of
results |

|
2006-11-07 03:47:45 |
Adam Dickmeiss wrote:
> Mark Jordan wrote:
>> Hi Adam,
>>
> I am confused about what you expected.. yaz_present
should send a
> present request using the range given. It does not
return anything. It's
> just a hint that you want a range to be returned. And
these results are
> inspected using yaz_record. You don't need yaz_present
in a program - in
> which case yaz_record will just fetch the record at
that point (one a
> time).
>
I expected to be able to retrieve records 11-20 in a given
result set by
using
$start = 11;
$number = 10;
yaz_range($id, $start, $number);
Since changing $start and $number don't seem to have any
effect on what
records are retrieved (see the code snippet I included in my
first
email), I thought that calling yaz_present() would. If
calling
yaz_present() is unnecessary, I suggest the docs should say
so instead
of implying that it should be called.
Perhaps John Durno's suggestion of getting the entire result
set and
then picking out subsets for display is easier.
Mark
_______________________________________________
Yazlist mailing list
Yazlist lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
|
|
| Using yaz_present to display subsets of
results |

|
2006-11-07 04:10:23 |
Hi Mark,
The problem, I think, is in your for() loop through the
records; I think
it indicates a misunderstanding about how yaz_record()
works. Generally,
the record offset that you give to yaz_record() is the
offset into the
result set, not into any subset identified by yaz_range().
This is
crucial: The yaz_range() function is strictly there to help
you write
more optimized client code; you do not need to call it.
In other words, if you want to display record numbers 10 to
20 from your
set, you loop from 10 to 20 and call yaz_record() for each
record. The
underlying code will retrieve records as necessary on
demand.
However, if you call yaz_range() before you call yaz_wait(),
the
underlying code will optimize it's behavior.. it will either
ask the
server to return records along with the search recult, or
submit a
single present request to fetch the records (if you're not
asking for
too many).. it makes no difference in a quick hack, but it
can make a
dramatic difference if you're designing for many users or
heavy traffic.
Your loop over yaz_record() will be the same whether you
have called
yaz_range() first, or not.
Looking at the documentation under php.net, I can understand
any
confusion.. the 'ZOOM' abstraction attempts to make things
as simple as
possible for the client programmers, allowing you to quickly
put
together useful applications without worrying about protocol
mechanics.
Functions like yaz_range() are there to help you write
better clients.
Hope this helps,
--Sebastian
Mark Jordan wrote:
> Hi Adam,
>
> I'm still missing something. Using yaz_syntax($id,
"usmarc") doesn't
> make a difference. Here's my entire script (with record
formatting
> removed -- it just prints records as XML):
>
> <?php
>
> $max_recs = 5;
> $query = $argv[1];
> $field = $argv[2];
> $start_at_rec = $argv[3];
> $query = trim($query);
> $field = trim($field);
>
> $fields = array('title' => '4', 'author' =>
'1003', 'subject' => '21');
>
> $query = ' attr 1=' . $fields[$field] . ' ' . $query;
> print "Query is $queryn";
> print "Starting at record $start_at_recn";
>
> $id = yaz_connect('troy.lib.sfu.ca:210/innopac');
> yaz_range($id, $start_at_rec, $max_recs);
> yaz_syntax($id, "usmarc");
> yaz_search($id, 'rpn', $query);
> yaz_wait();
>
> $error = yaz_error($id);
> if (!empty($error)) {
> echo "Error: $error";
> print "n";
> exit;
> } else {
> $hits = yaz_hits($id);
> if ($hits == '0') {
> print "No hitsn";
> exit;
> }
> }
>
> for ($p = 1; $p <= $max_recs; $p++) {
> $rec = yaz_record($id, $p, "xml; marc-8,
utf-8");
> if (empty($rec)) continue;
> print $rec;
> }
>
> ?>
>
> BTW I'm using PHP/YAZ version 1.0.7, YAZ version
2.1.36, PHP 5.1.6 on
> FedoraCore 5/ppc.
>
> Mark
>
> Adam Dickmeiss wrote:
>
>> Mark Jordan wrote:
>>
>>> Hello,
>>>
>>> I have been unable to figure out how to use the
yaz_present()
>>> function to return subsets of my entire result
set. I couldn't find
>>> a functional example anywhere (inc. the PHP
docs and the yaz mailing
>>> list archives) so was hoping someone can tell
me what I'm doing wrong.
>>>
>>> In the following example, changing the value of
$start has no effect
>>> on the records returned by by my search:
>>>
>>> $start = '1';
>>> $number = '5';
>>> $query = ' attr 1=4 test';
>>> $id =
yaz_connect('troy.lib.sfu.ca:210/innopac');
>>> yaz_range($id, $start, $number);
>>> yaz_syntax($id, 'marc21');
>>
>>
>> Use
>> yaz_syntax($id, "usmarc");
>> instead.
>>
>>> yaz_search($id, 'rpn', $query);
>>> yaz_present($id);
>>
>> It should not be necessary to use yaz_present.
(yaz_search will get
>> the range).
>>
>> / Adam
>>
>>> yaz_wait();
>>>
>>> // Formatting of results using XSL omitted
>>>
>>>
>>> Number of records found: 1578
>>> =============================
>>> The biplane houses :poems /by Les Murray.
>>> Embedded system design /by Peter Marwedel.
>>> Hardening Windows systems /Roberta Bragg.
>>> Java 2 :the complete reference /Patrick
Naughton, Herbert Schildt.
>>> Practical MMIC design /Steve Marsh.
>>>
>>>
>>> Since yaz_present() only takes the resource ID
as a parameter, and
>>> only returns TRUE or FALSE, I'm not sure how
else it would be used
>>> to produce results. The docs are sparse on this
topic.
>>>
>>> Any pointers to complete examples, or to what I
am doing wrong,
>>> would be appreciated. I'd be happy to post my
complete script when
>>> it is working.
>>>
>>> Mark
>>>
>>> Mark Jordan
>>> Head of Library Systems
>>> W.A.C. Bennett Library, Simon Fraser University
>>> Burnaby, British Columbia, V5A 1S6, Canada
>>> Phone (604) 291 5753 / Fax (604) 291 3023
>>> mjordan sfu.ca / http://www.sfu.ca/~mjorda
n/
>>>
>
>
> _______________________________________________
> Yazlist mailing list
> Yazlist lists.indexdata.dk
> http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
>
>
--
Sebastian Hammer, Index Data
quinn indexdata.com www.indexdata.com
Ph: (603) 209-6853 Fax: (866) 383-4485
_______________________________________________
Yazlist mailing list
Yazlist lists.indexdata.dk
http://lists.indexdata.dk/cgi-bin/mailman/listinfo/yaz
list
|
|
[1-7]
|
|