Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : YAZ Functions : yaz_search

yaz_search

Prepares for a search (PHP 4 >= 4.0.1, PECL yaz:0.9-1.0.9)
bool yaz_search ( resource id, string type, string query )

yaz_search() prepares for a search on the given connection.

Like yaz_connect() this function is non-blocking and only prepares for a search to be executed later when yaz_wait() is called.

Parameters

id

The connection resource returned by yaz_connect().

type

This parameter represents the query type - only "rpn" is supported now in which case the third argument specifies a Type-1 query in prefix query notation.

query

The RPN query is a textual representation of the Type-1 query as defined by the Z39.50 standard. However, in the text representation as used by YAZ a prefix notation is used, that is the operator precedes the operands. The query string is a sequence of tokens where white space is ignored unless surrounded by double quotes. Tokens beginning with an at-character (@) are considered operators, otherwise they are treated as search terms.

Table 344. RPN Operators

Construct Description
@and query1 query2 intersection of query1 and query2
@or query1 query2 union of query1 and query2
@not query1 query2 query1 and not query2
@set name result set reference
@attrset set query specifies attribute-set for query. This construction is only allowed once - in the beginning of the whole query
@attr [set] type=value query applies attribute to query. The type and value are integers specifying the attribute-type and attribute-value respectively. The set, if given, specifies the attribute-set.


You can find information about attributes at the » Z39.50 Maintenance Agency site.

Note:

If you would like to use a more friendly notation, use the CCL parser - functions yaz_ccl_conf() and yaz_ccl_parse().

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example 2679. Query Examples

You can search for simple terms, like this:

computer

which matches documents where "computer" occur. No attributes are specified.

The query

"knuth donald"

matches documents where "knuth donald" occur (provided that the server supports phrase search).

This query applies two attributes for the same phrase.

@attr 1=1003 @attr 4=1 "knuth donald"

First attribute is type 1 (Bib-1 use), attribute value is 1003 (Author). Second attribute has is type 4 (structure), value 1 (phrase), so this should match documents where Donald Knuth is author.

The query

@and @or a b @not @or c d e

would in infix notation look like (a or b) and ((c or d) not e).

Another, more complex, one:

@attrset gils @and @attr 1=4 art @attr 1=2000 company

The query as a whole uses the GILS attributeset. The query matches documents where art occur in the title (GILS,BIB-1) and in which company occur as Distributor (GILS).


Code Examples / Notes » yaz_search

sean

You can find the full Bib-1 attribute set at http://www.loc.gov/z3950/agency/defns/bib1.html

jwohlers

Quick Reference For Attribute Fields
(eg: "@attr 2=" refers to the Relation attribute)
1 = Use Field
2 = Relation
3 = Position
4 = Structure
5 = Truncate
6 = Completeness


Change Language


Follow Navioo On Twitter
yaz_addinfo
yaz_ccl_conf
yaz_ccl_parse
yaz_close
yaz_connect
yaz_database
yaz_element
yaz_errno
yaz_error
yaz_es_result
yaz_es
yaz_get_option
yaz_hits
yaz_itemorder
yaz_present
yaz_range
yaz_record
yaz_scan_result
yaz_scan
yaz_schema
yaz_search
yaz_set_option
yaz_sort
yaz_syntax
yaz_wait
eXTReMe Tracker