<HTML ><HEAD ><TITLE >yaz_search</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="YAZ functions" HREF="ref.yaz.html"><LINK REL="PREVIOUS" TITLE="yaz_schema" HREF="function.yaz-schema.html"><LINK REL="NEXT" TITLE="yaz_set_option" HREF="function.yaz-set-option.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.yaz-schema.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.yaz-set-option.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.yaz-search" ></A >yaz_search</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN97951" ></A ><P > (PHP 4 >= 4.0.1)</P >yaz_search -- Prepares for a search</DIV ><DIV CLASS="refsect1" ><A NAME="AEN97954" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >yaz_search</B > ( resource id, string type, string query)<BR ></BR ><P > <B CLASS="function" >yaz_search()</B > prepares for a search on the connection given by <TT CLASS="parameter" ><I >id</I ></TT >. The <TT CLASS="parameter" ><I >type</I ></TT > represents the query type - only <TT CLASS="literal" >"rpn"</TT > is supported now in which case the third argument specifies a Type-1 query in prefix query notation. Like <A HREF="function.yaz-connect.html" ><B CLASS="function" >yaz_connect()</B ></A > this function is non-blocking and only prepares for a search to be executed later when <A HREF="function.yaz-wait.html" ><B CLASS="function" >yaz_wait()</B ></A > is called. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN97975" ></A ><H2 >The RPN query</H2 ><P > The RPN query is a textual represenation 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 operater precedes the operands. The query string is a sequence of tokens where white space is ignored is ignored unless surrounded by double quotes. Tokens beginning with an at-character (<TT CLASS="literal" >@</TT >) are considered operators, otherwise they are treated as search terms. </P ><DIV CLASS="table" ><A NAME="AEN97979" ></A ><P ><B >Table 1. RPN Operators</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH WIDTH="33%" ALIGN="LEFT" VALIGN="MIDDLE" >Construct</TH ><TH WIDTH="67%" ALIGN="LEFT" VALIGN="MIDDLE" >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD WIDTH="33%" ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >@and</TT > query1 query2</TD ><TD WIDTH="67%" ALIGN="LEFT" VALIGN="MIDDLE" >intersection of query1 and query2</TD ></TR ><TR ><TD WIDTH="33%" ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >@or</TT > query1 query2</TD ><TD WIDTH="67%" ALIGN="LEFT" VALIGN="MIDDLE" >union of query1 and query2</TD ></TR ><TR ><TD WIDTH="33%" ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >@not</TT > query1 query2</TD ><TD WIDTH="67%" ALIGN="LEFT" VALIGN="MIDDLE" >query1 and not query2</TD ></TR ><TR ><TD WIDTH="33%" ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >@set</TT > name</TD ><TD WIDTH="67%" ALIGN="LEFT" VALIGN="MIDDLE" >result set reference</TD ></TR ><TR ><TD WIDTH="33%" ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >@attrset</TT > set query</TD ><TD WIDTH="67%" ALIGN="LEFT" VALIGN="MIDDLE" >specifies attribute-set for query. This construction is only allowed once - in the beginning of the whole query</TD ></TR ><TR ><TD WIDTH="33%" ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="literal" >@attr</TT > [set] type=value query</TD ><TD WIDTH="67%" ALIGN="LEFT" VALIGN="MIDDLE" >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.</TD ></TR ></TBODY ></TABLE ></DIV ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN98013" ></A ><P ><B >Example 1. Query Examples</B ></P ><P > You can search for simple terms, like this <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >computer</PRE ></TD ></TR ></TABLE > which matches documents where "computer" occur. No attributes are specified. </P ><P > The Query <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >"knuth donald"</PRE ></TD ></TR ></TABLE > matches documents where "knuth donald" occur (provided that the server supports phrase search). </P ><P > This query applies two attributes for the same phrase. <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >@attr 1=1003 @attr 4=1 "knuth donald"</PRE ></TD ></TR ></TABLE > 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. </P ><P > This query <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >@and @or a b @not @or c d e</PRE ></TD ></TR ></TABLE > would in infix notation look like <TT CLASS="literal" >(a or b) and ((c or d) not e)</TT >. </P ><P > Another, more complex, one: <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >@attrset gils @and @attr 1=4 art @attr 1=2000 company</PRE ></TD ></TR ></TABLE > The query as a whole uses the GILS attributeset. The query matches documents where <TT CLASS="literal" >art</TT > occur in the title (GILS,BIB-1) and in which <TT CLASS="literal" >company</TT > occur as Distributor (GILS). </P ></DIV ></TD ></TR ></TABLE ><P > You can find information about attributes at the <A HREF="http://www.loc.gov/z3950/agency/defns/bib1.html" TARGET="_top" >Z39.50 Maintenance Agency</A > site. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > If you would like to use a more friendly notation, use the CCL parser - functions <A HREF="function.yaz-ccl-conf.html" ><B CLASS="function" >yaz_ccl_conf()</B ></A > and <A HREF="function.yaz-ccl-parse.html" ><B CLASS="function" >yaz_ccl_parse()</B ></A >. </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.yaz-schema.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.yaz-set-option.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >yaz_schema</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.yaz.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >yaz_set_option</TD ></TR ></TABLE ></DIV ></BODY ></HTML >