<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Swish Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="swf_viewport" HREF="function.swf-viewport.html"><LINK REL="NEXT" TITLE="Swish::__construct" HREF="function.swish-construct.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="reference" 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" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.swf-viewport.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.swish-construct.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.swish" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >CLXIII. Swish Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN224819" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="swish.intro" >Introdução</A ></H1 ><P > The swish extension provides the bindings for Swish-e API. Swish-e stands for "Simple Web Indexing System for Humans - Enhanced" and is an open source system for indexing and search. Swish-e itself is licensed under GPL license, but uses a clause that allows applications to link against the library if every copy of the combined work is accompanied by the URL to Swish-e source code. Here it is: <A HREF="http://swish-e.org" TARGET="_top" >http://swish-e.org</A >. </P ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Atenção</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P >Este módulo é <SPAN CLASS="emphasis" ><I CLASS="emphasis" >EXPERIMENTAL</I ></SPAN >. Isso quer dizer que o comportamento neste módulo --- incluindo suas funções e seus nomes, e TUDO mais que está documentado sobre esse módulo --- poderá mudar em futuras versões do PHP, SEM QUALQUER NOTIFICAÇÃO. Esteja avisado, e use este módulo por sua própria conta e risco.</P ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="swish.requirements" >Dependências</A ></H1 ><P > PECL/swish requires PHP 5.1.3 or newer. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="swish.install" >Instalação</A ></H1 ><P > Informações para a instalação desta extensão PECL podem ser encontradas no manual no capitulo entitulado <A HREF="install.pecl.html" >Instalação de extensões PECL</A >. Informações adicionais como novas versões, downloads, arquivos fontes, manutenções, e um Changelog, podem ser obtidos aqui: <A HREF="http://pecl.php.net/package/swish" TARGET="_top" >http://pecl.php.net/package/swish</A >. </P ><P > The latest PECL/swish Win32 DLL can be downloaded here: <A HREF="http://pecl4win.php.net/ext.php/php_swish.dll" TARGET="_top" >php_swish.dll</A >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="swish.configuration" >Configurações em execução</A ></H1 ><P >Esta extensão não define nenhum parâmetro de configuração no <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="swish.examples" >Exemplos</A ></H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN224844" ></A ><P ><B >Exemplo 1. Basic search query</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /><br />try </font><font color="#007700">{<br /><br /> </font><font color="#0000BB">$swish </font><font color="#007700">= new </font><font color="#0000BB">Swish</font><font color="#007700">(</font><font color="#DD0000">"index.swish-e"</font><font color="#007700">);<br /> </font><font color="#0000BB">$results </font><font color="#007700">= </font><font color="#0000BB">$swish</font><font color="#007700">-></font><font color="#0000BB">query</font><font color="#007700">(</font><font color="#DD0000">"test OR text"</font><font color="#007700">);<br /><br /> echo </font><font color="#DD0000">"Found "</font><font color="#007700">, </font><font color="#0000BB">$results</font><font color="#007700">-></font><font color="#0000BB">hits</font><font color="#007700">, </font><font color="#DD0000">" results\n"</font><font color="#007700">;<br /> while (</font><font color="#0000BB">$result </font><font color="#007700">= </font><font color="#0000BB">$results</font><font color="#007700">-></font><font color="#0000BB">nextResult</font><font color="#007700">()) {<br /> </font><font color="#0000BB">var_dump</font><font color="#007700">(</font><font color="#0000BB">$result</font><font color="#007700">);<br /> break; </font><font color="#FF8000">//break after the first result<br /> </font><font color="#007700">}<br /><br />} </font><font color="#0000BB">catch </font><font color="#007700">(</font><font color="#0000BB">SwishException $e</font><font color="#007700">) {<br /> echo </font><font color="#DD0000">"Error: "</font><font color="#007700">, </font><font color="#0000BB">$e</font><font color="#007700">-></font><font color="#0000BB">getMessage</font><font color="#007700">(), </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />}<br /><br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P >O exemplo acima irá imprimir algo similar a:</P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >Found 9 results object(SwishResult)#3 (8) { ["swishreccount"]=> int(1) ["swishrank"]=> int(1000) ["swishfilenum"]=> int(10) ["swishdbfile"]=> string(13) "index.swish-e" ["swishdocpath"]=> string(23) "README.SUBMITTING_PATCH" ["swishtitle"]=> NULL ["swishdocsize"]=> int(4557) ["swishlastmodified"]=> int(1072136752) }</PRE ></TD ></TR ></TABLE ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="swish.constants" >Constantes pré-definidas</A ></H1 ><P > As contantes abaixo são definidas por esta extensão e somente estarão disponíveis quando a extensão foi compilada com o PHP ou carregada dinamicamente durante a execução. </P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >Swish::META_TYPE_UNDEF</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::META_TYPE_STRING</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::META_TYPE_ULONG</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::META_TYPE_DATE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_FILE_BIT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_TITLE_BIT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_HEAD_BIT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_BODY_BIT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_COMMENTS_BIT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_HEADER_BIT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_EMPHASIZED_BIT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_META_BIT</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_FILE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_TITLE</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_HEAD</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_BODY</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_COMMENTS</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_HEADER</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_EMPHASIZED</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_META</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >Swish::IN_ALL</B ></TT > (<A HREF="language.types.integer.html" ><B CLASS="type" >integer</B ></A >)</DT ><DD ><P > </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="swish.classes" >Classes pré-definidas</A ></H1 ><DIV CLASS="section" ><H2 CLASS="section" ><A NAME="AEN224981" >Classes pré-definidas</A ></H2 ><DIV CLASS="section" ><H3 CLASS="section" ><A NAME="swish.class.swish" ><B CLASS="classname" >Swish</B ></A ></H3 ><P > </P ><DIV CLASS="section" ><H4 CLASS="section" ><A NAME="swish.class.swish.properties" >Propriedades</A ></H4 ><P ></P ><UL ><LI ><P > <SPAN CLASS="property" >indexes</SPAN > - the array of indexes used and their properties. Certain list of properties depends on Swish-e version. </P ></LI ></UL ></DIV ><DIV CLASS="section" ><H4 CLASS="section" ><A NAME="swish.class.swish.methods" >Métodos</A ></H4 ><P ></P ><UL ><LI ><P > <A HREF="function.swish-construct.html" >Swish::__construct</A > - constructs new <B CLASS="classname" >Swish</B > object. Throws <B CLASS="classname" >SwishException</B > on error. </P ></LI ><LI ><P > <A HREF="function.swish-prepare.html" >Swish->prepare</A > - prepares and returns <B CLASS="classname" >SwishSearch</B > object. Throws <B CLASS="classname" >SwishException</B > on error. </P ></LI ><LI ><P > <A HREF="function.swish-query.html" >Swish->query</A > - executes the query and returns <B CLASS="classname" >SwishResults</B > object. Throws <B CLASS="classname" >SwishException</B > on error. </P ></LI ><LI ><P ><A HREF="function.swish-getmetalist.html" >Swish->getMetaList</A > - returns an array of meta entries for the given index file.</P ></LI ><LI ><P ><A HREF="function.swish-getpropertylist.html" >Swish->getPropertyList</A > - returns an array of properties for the given index file.</P ></LI ></UL ></DIV ></DIV ><DIV CLASS="section" ><H3 CLASS="section" ><A NAME="swish.class.swishsearch" ><B CLASS="classname" >SwishSearch</B ></A ></H3 ><P > </P ><DIV CLASS="section" ><H4 CLASS="section" ><A NAME="swish.class.swishsearch.methods" >Métodos</A ></H4 ><P ></P ><UL ><LI ><P > <A HREF="function.swishsearch-setstructure.html" >SwishSearch->setStructure</A > - sets the structure flag in the search object. This flag is used to limit search to certain parts of HTML documents. </P ></LI ><LI ><P > <A HREF="function.swishsearch-setphrasedelimiter.html" >SwishSearch->setPhraseDelimiter</A > - sets the phrase delimiter character. The default delimiter is double-quotes. </P ></LI ><LI ><P > <A HREF="function.swishsearch-setsort.html" >SwishSearch->setSort</A > - sets the sort order of the results. </P ></LI ><LI ><P > <A HREF="function.swishsearch-setlimit.html" >SwishSearch->setLimit</A > - sets the limits for the search. Throws <B CLASS="classname" >SwishException</B > on error. </P ></LI ><LI ><P > <A HREF="function.swishsearch-resetlimit.html" >SwishSearch->resetLimit</A > - resets the limits. </P ></LI ><LI ><P > <A HREF="function.swishsearch-execute.html" >SwishSearch->execute</A > - executes the query and returns <B CLASS="classname" >SwishResults</B > object. Throws <B CLASS="classname" >SwishException</B > on error. </P ></LI ></UL ></DIV ></DIV ><DIV CLASS="section" ><H3 CLASS="section" ><A NAME="swish.class.swishresults" ><B CLASS="classname" >SwishResults</B ></A ></H3 ><P > </P ><DIV CLASS="section" ><H4 CLASS="section" ><A NAME="swish.class.swishresults.properties" >Propriedades</A ></H4 ><P ></P ><UL ><LI ><P > <SPAN CLASS="property" >hits</SPAN > - the number of results in this <B CLASS="classname" >SwishResults</B > object. </P ></LI ><LI ><P > <SPAN CLASS="property" >indexes</SPAN > - the array of indexes used in the search. </P ></LI ></UL ></DIV ><DIV CLASS="section" ><H4 CLASS="section" ><A NAME="swish.class.swishresults.methods" >Métodos</A ></H4 ><P ></P ><UL ><LI ><P > <A HREF="function.swishresults-nextresult.html" >SwishResults->nextResult</A > - returns next <B CLASS="classname" >SwishResult</B > object or <TT CLASS="constant" ><B >FALSE</B ></TT > if no more results are available. </P ></LI ><LI ><P > <A HREF="function.swishresults-seekresult.html" >SwishResults->seekResult</A > - sets the current seek position in the <B CLASS="classname" >SwishResults</B > object. Throws <B CLASS="classname" >SwishException</B > on error. </P ></LI ><LI ><P > <A HREF="function.swishresults-getparsedwords.html" >SwishResults->getParsedWords</A > - returns an array of words in the query with stopwords removed. </P ></LI ><LI ><P > <A HREF="function.swishresults-getremovedstopwords.html" >SwishResults->getRemovedStopwords</A > - returns an array of removed stopwords. </P ></LI ></UL ></DIV ></DIV ><DIV CLASS="section" ><H3 CLASS="section" ><A NAME="swish.class.swishresult" ><B CLASS="classname" >SwishResult</B ></A ></H3 ><P > </P ><DIV CLASS="section" ><H4 CLASS="section" ><A NAME="swish.class.swishresult.properties" >Propriedades</A ></H4 ><P ></P ><UL ><LI ><P >Properties list depends on Swish-e version, see examples.</P ></LI ></UL ></DIV ><DIV CLASS="section" ><H4 CLASS="section" ><A NAME="swish.class.swishresult.methods" >Métodos</A ></H4 ><P ></P ><UL ><LI ><P > <A HREF="function.swishresult-getmetalist.html" >SwishResult->getMetaList</A > - returns an array of meta entries for the index used in this result. </P ></LI ><LI ><P > <A HREF="function.swishresult-stem.html" >SwishResult->stem</A > - stems the word and returns result as an array of strings. Throws <B CLASS="classname" >SwishException</B > on error. </P ></LI ></UL ></DIV ></DIV ><DIV CLASS="section" ><H3 CLASS="section" ><A NAME="swish.class.swishexception" ><B CLASS="classname" >SwishException</B ></A ></H3 ><P > <B CLASS="classname" >SwishException</B > extends the built in <B CLASS="classname" >Exception</B > class and possesses the same set of properties and methods. See <A HREF="language.exceptions.html#language.exceptions.extending" >a seção <I >Herdando Exceções</I > Capítulo 20</A > for more details. </P ></DIV ></DIV ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.swish-construct.html" >Swish::__construct</A > -- Construct a Swish object</DT ><DT ><A HREF="function.swish-getmetalist.html" >Swish->getMetaList</A > -- Get the list of meta entries for the index</DT ><DT ><A HREF="function.swish-getpropertylist.html" >Swish->getPropertyList</A > -- Get the list of properties for the index</DT ><DT ><A HREF="function.swish-prepare.html" >Swish->prepare</A > -- Prepare a search query</DT ><DT ><A HREF="function.swish-query.html" >Swish->query</A > -- Execute a query and return results object</DT ><DT ><A HREF="function.swishresult-getmetalist.html" >SwishResult->getMetaList</A > -- Get a list of meta entries</DT ><DT ><A HREF="function.swishresult-stem.html" >SwishResult->stem</A > -- Stems the given word</DT ><DT ><A HREF="function.swishresults-getparsedwords.html" >SwishResults->getParsedWords</A > -- Get an array of parsed words</DT ><DT ><A HREF="function.swishresults-getremovedstopwords.html" >SwishResults->getRemovedStopwords</A > -- Get an array of stopwords removed from the query</DT ><DT ><A HREF="function.swishresults-nextresult.html" >SwishResults->nextResult</A > -- Get the next search result</DT ><DT ><A HREF="function.swishresults-seekresult.html" >SwishResults->seekResult</A > -- Set current seek pointer to the given position</DT ><DT ><A HREF="function.swishsearch-execute.html" >SwishSearch->execute</A > -- Execute the search and get the results</DT ><DT ><A HREF="function.swishsearch-resetlimit.html" >SwishSearch->resetLimit</A > -- Reset the search limits</DT ><DT ><A HREF="function.swishsearch-setlimit.html" >SwishSearch->setLimit</A > -- Set the search limits</DT ><DT ><A HREF="function.swishsearch-setphrasedelimiter.html" >SwishSearch->setPhraseDelimiter</A > -- Set the phrase delimiter</DT ><DT ><A HREF="function.swishsearch-setsort.html" >SwishSearch->setSort</A > -- Set the sort order</DT ><DT ><A HREF="function.swishsearch-setstructure.html" >SwishSearch->setStructure</A > -- Set the structure flag in the search object</DT ></DL ></DIV ></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.swf-viewport.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.swish-construct.html" ACCESSKEY="N" >Próxima</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >swf_viewport</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Swish::__construct</TD ></TR ></TABLE ></DIV ></BODY ></HTML >