PECL/swish documentation

===============================
Native speaker review required.
===============================


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@229415 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Antony Dovgal 2007-02-09 13:35:21 +00:00
parent 48af34847f
commit e712747cea
20 changed files with 2219 additions and 0 deletions

222
reference/swish/classes.xml Normal file
View file

@ -0,0 +1,222 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<section id="swish.classes">
&reftitle.classes;
<section>
&reftitle.classes;
<section id="swish.class.swish">
<title><classname>Swish</classname></title>
<para>
</para>
<section id="swish.class.swish.properties">
&reftitle.properties;
<itemizedlist>
<listitem>
<para>
<property>indexes</property> - the array of indexes used and their properties. Certain
list of properties depends on Swish-e version.
</para>
</listitem>
</itemizedlist>
</section>
<section id="swish.class.swish.methods">
&reftitle.methods;
<itemizedlist>
<listitem>
<para>
<xref linkend="function.swish-construct" /> - constructs new
<classname>Swish</classname> object.
Throws <classname>SwishException</classname> on error.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swish-prepare" /> - prepares and returns
<classname>SwishSearch</classname> object.
Throws <classname>SwishException</classname> on error.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swish-query" /> - executes the query and
returns <classname>SwishResults</classname> object.
Throws <classname>SwishException</classname> on error.
</para>
</listitem>
<listitem>
<para><xref linkend="function.swish-getMetaList" /> - returns an array
of meta entries for the given index file.</para>
</listitem>
<listitem>
<para><xref linkend="function.swish-getPropertyList" /> - returns an array
of properties for the given index file.</para>
</listitem>
</itemizedlist>
</section>
</section>
<section id="swish.class.swishsearch">
<title><classname>SwishSearch</classname></title>
<para>
</para>
<section id="swish.class.swishsearch.methods">
&reftitle.methods;
<itemizedlist>
<listitem>
<para>
<xref linkend="function.swishsearch-setStructure" /> - sets the
structure flag in the search object. This flag is used to limit search
to certain parts of HTML documents.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swishsearch-setPhraseDelimiter" /> - sets
the phrase delimiter character. The default delimiter is double-quotes.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swishsearch-setSort" /> - sets the sort
order of the results.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swishsearch-setLimit" /> - sets the limits
for the search.
Throws <classname>SwishException</classname> on error.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swishsearch-resetLimit" /> - resets the
limits.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swishsearch-execute" /> - executes the
query and returns <classname>SwishResults</classname> object.
Throws <classname>SwishException</classname> on error.
</para>
</listitem>
</itemizedlist>
</section>
</section>
<section id="swish.class.swishresults">
<title><classname>SwishResults</classname></title>
<para>
</para>
<section id="swish.class.swishresults.properties">
&reftitle.properties;
<itemizedlist>
<listitem>
<para>
<property>hits</property> - the number of results in this
<classname>SwishResults</classname> object.
</para>
</listitem>
<listitem>
<para>
<property>indexes</property> - the array of indexes used in the search.
</para>
</listitem>
</itemizedlist>
</section>
<section id="swish.class.swishresults.methods">
&reftitle.methods;
<itemizedlist>
<listitem>
<para>
<xref linkend="function.swishresults-nextResult" /> - returns
next <classname>SwishResult</classname> object or &false; if no
more results are available.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swishresults-seekResult" /> - sets the
current seek position in the <classname>SwishResults</classname>
object.
Throws <classname>SwishException</classname> on error.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swishresults-getParsedWords" /> -
returns an array of words in the query with stopwords removed.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swishresults-getRemovedStopwords" /> -
returns an array of removed stopwords.
</para>
</listitem>
</itemizedlist>
</section>
</section>
<section id="swish.class.swishresult">
<title><classname>SwishResult</classname></title>
<para>
</para>
<section id="swish.class.swishresult.properties">
&reftitle.properties;
<itemizedlist>
<listitem>
<para>Properties list depends on Swish-e version, see examples.</para>
</listitem>
</itemizedlist>
</section>
<section id="swish.class.swishresult.methods">
&reftitle.methods;
<itemizedlist>
<listitem>
<para>
<xref linkend="function.swishresult-getMetaList" /> - returns
an array of meta entries for the index used in this result.
</para>
</listitem>
<listitem>
<para>
<xref linkend="function.swishresult-stem" /> - stems the word
and returns result as an array of strings.
Throws <classname>SwishException</classname> on error.
</para>
</listitem>
</itemizedlist>
</section>
</section>
<section id="swish.class.swishexception">
<title><classname>SwishException</classname></title>
<para>
<classname>SwishException</classname> extends the build in
<classname>Exception</classname> class and possesses the same set of
properties and methods. See <xref
linkend="language.exceptions.extending"/> for more details.
</para>
</section>
</section>
</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,240 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<section id="swish.constants">
&reftitle.constants;
&extension.constants;
<variablelist>
<varlistentry>
<term>
<constant>SWISH_META_TYPE_UNDEF</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_META_TYPE_STRING</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_META_TYPE_ULONG</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_META_TYPE_DATE</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_FILE_BIT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_TITLE_BIT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_HEAD_BIT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_BODY_BIT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_COMMENTS_BIT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_HEADER_BIT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_EMPHASIZED_BIT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_META_BIT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_FILE</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_TITLE</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_HEAD</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_BODY</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_COMMENTS</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_HEADER</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_EMPHASIZED</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_META</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>SWISH_IN_ALL</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
</simpara>
</listitem>
</varlistentry>
</variablelist>
</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swish-construct">
<refnamediv>
<refname>Swish::__construct</refname>
<refpurpose>Construct a Swish object</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>void</type><methodname>Swish::__construct</methodname>
<methodparam><type>string</type><parameter>string index_names</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>index_names</parameter></term>
<listitem>
<para>
The list of index files separated by spaces.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>SwishException</classname> on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>Swish::__construct</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index1 index2");
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
foreach ($swish->indexes as $index) {
var_dump($index["name"]);
var_dump($index["headers"]["Total Words"]);
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
string(6) "index1"
int(1888)
string(6) "index2"
int(2429)
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swish-getMetaList">
<refnamediv>
<refname>Swish-&gt;getMetaList</refname>
<refpurpose>Get the list of meta entries for the index</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>Swish-&gt;getMetaList</methodname>
<methodparam><type>string</type><parameter>index_name</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>index_name</parameter></term>
<listitem>
<para>
The name of the index file.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an array of meta entries for the given index.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>Swish-&gt;getMetaList</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
var_dump($swish->getMetaList("index.swish-e"));
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
array(1) {
[0]=>
array(3) {
["Name"]=>
string(12) "swishdefault"
["Type"]=>
int(0)
["ID"]=>
int(1)
}
}
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swish-getPropertyList">
<refnamediv>
<refname>Swish-&gt;getPropertyList</refname>
<refpurpose>Get the list of properties for the index</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>Swish-&gt;getPropertyList</methodname>
<methodparam><type>string</type><parameter>index_name</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>index_name</parameter></term>
<listitem>
<para>
The name of the index file.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an array of properties for the given index.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>Swish-&gt;getPropertyList</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$properties = $swish->getPropertyList("index.swish-e");
foreach ($properties as $prop) {
echo $prop["Name"],"\n";
}
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
swishreccount
swishrank
swishfilenum
swishdbfile
swishdocpath
swishtitle
swishdocsize
swishlastmodified
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swish-prepare">
<refnamediv>
<refname>Swish-&gt;prepare</refname>
<refpurpose>Prepare a search query</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>object</type><methodname>Swish-&gt;prepare</methodname>
<methodparam choice="opt"><type>string</type><parameter>query</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
Prepare and return a search object, which you can later use for unlimited
number of queries.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>query</parameter></term>
<listitem>
<para>
Optional query string. The query can be also set using <link
linkend="function.swishsearch-execute"><function>SwishSearch-&gt;execute</function></link>
method.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns <classname>SwishSearch</classname> object.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>SwishException</classname> on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>Swish-&gt;prepare</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare("search query");
$results = $search->execute();
echo "Found: ", $results->hits, " hits\n";
$results = $search->execute("new search");
echo "Found: ", $results->hits, " hits\n";
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
Found: 2 hits
Found: 5 hits
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swish-query">
<refnamediv>
<refname>Swish-&gt;query</refname>
<refpurpose>Execute a query and return results object</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>object</type><methodname>Swish-&gt;query</methodname>
<methodparam><type>string</type><parameter>query</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
A quick method to execute a search with default parameters.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>query</parameter></term>
<listitem>
<para>
Query string.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns <classname>SwishResults</classname> object.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>SwishException</classname> on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>Swish-&gt;query</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$results = $swish->query("test query");
echo "Found: ", $results->hits, " hits\n";
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
Found: 1 hits
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishresult-getMetaList">
<refnamediv>
<refname>SwishResult-&gt;getMetaList</refname>
<refpurpose>Get a list of meta entries</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>SwishResult-&gt;getMetaList</methodname>
<void/>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the same array as <link
linkend="function.swish-getMetaList"><function>Swish-&gt;getMetaList</function></link>,
but uses the index file from the result handle.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishresult-stem">
<refnamediv>
<refname>SwishResult-&gt;stem</refname>
<refpurpose>Stems the given word</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>SwishResult-&gt;stem</methodname>
<methodparam><type>string</type><parameter>word</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
Stems the word based on the fuzzy mode used during indexing.
Each result object is linked with its index, so the results are based on this index.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>word</parameter></term>
<listitem>
<para>
The word to stem.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns array of results, in most cases with just one element.
If the stemmer used does not convert the word, the result array will
contain the original word.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>SwishException</classname> on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function></function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("ext/swish/tests/index.swish-e");
$results = $swish->query("testing OR others");
if ($result = $results->nextResult()) {
var_dump($result->stem("testing")); //the results fully depend on the stemmer used in th index
var_dump($result->stem("others"));
}
} catch (SwishException $e) {
echo "Error: ", $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
array(1) {
[0]=>
string(4) "test"
}
array(1) {
[0]=>
string(5) "other"
}
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishresults-getParsedWords">
<refnamediv>
<refname>SwishResults-&gt;getParsedWords</refname>
<refpurpose>Get an array of parsed words</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>SwishResults-&gt;getParsedWords</methodname>
<methodparam><type>string</type><parameter>index_name</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>indexi_name</parameter></term>
<listitem>
<para>
The name of the index used to initialize <classname>Swish</classname>
object.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
An array of parsed words with stopwords removed. The list of parsed words
may be useful for highlighting search terms in the results.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>SwishResults-&gt;getParsedWords</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$results = $swish->query("'some characters' and numbers");
var_dump($results->getParsedWords("index.swish-e"));
var_dump($results->indexes[0]['parsed_words']); //same result in a different way
} catch (SwishException $e) {
echo "Error: ", $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
array(4) {
[0]=>
string(4) "some"
[1]=>
string(10) "characters"
[2]=>
string(3) "and"
[3]=>
string(7) "numbers"
}
array(4) {
[0]=>
string(4) "some"
[1]=>
string(10) "characters"
[2]=>
string(3) "and"
[3]=>
string(7) "numbers"
}
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishresults-getRemovedStopwords">
<refnamediv>
<refname>SwishResults-&gt;getRemovedStopwords</refname>
<refpurpose>Get an array of stopwords removed from the query</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>SwishResults-&gt;getRemovedStopwords</methodname>
<methodparam><type>string</type><parameter>index_name</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>index_name</parameter></term>
<listitem>
<para>
The name of the index used to initialize <classname>Swish</classname>
object.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns array of stopwords removed from the query.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishresults-nextResult">
<refnamediv>
<refname>SwishResults-&gt;nextResult</refname>
<refpurpose>Get the next search result</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>object</type><methodname>SwishResults-&gt;nextResult</methodname>
<void/>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the next <classname>SwishResult</classname> object in the result
set or &false; if there are no more results available.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>SwishResults-&gt;nextResult</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare();
$results = $search->execute("lost");
while($result = $results->nextResult()) {
/* do something with the result object */
}
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishresults-seekResult">
<refnamediv>
<refname>SwishResults-&gt;seekResult</refname>
<refpurpose>Set current seek pointer to the given position</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>SwishResults-&gt;seekResult</methodname>
<methodparam><type>int</type><parameter>position</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>position</parameter></term>
<listitem>
<para>
Zero-based position number. Cannot be less than zero.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns new position value on success.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>SwishException</classname> on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>SwishResults-&gt;seekResult</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare();
$results = $search->execute("lost");
var_dump($results->seekResult(0)); //this will succeed
var_dump($results->seekResult(100)); //this will fail
} catch (SwishException $e) {
echo "Error: ", $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
int(0)
Error: No more results
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishsearch-execute">
<refnamediv>
<refname>SwishSearch-&gt;execute</refname>
<refpurpose>Execute the search and get the results</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>object</type><methodname>SwishSearch-&gt;execute</methodname>
<methodparam choice="opt"><type>string</type><parameter>query</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
<para>
Searches the index file(s) based on the parameters set in the search
object.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>query</parameter></term>
<listitem>
<para>
The query string is an optional parameter, it can be also set using
<link
linkend="function.swish-prepare"><function>Swish-&gt;prepare</function></link>
method. The query string is preserved between executions, so you can
set it once, but execute the search multiple times.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns <classname>SwishResults</classname> object.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>SwishException</classname> on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>SwishSearch-&gt;execute</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare();
$results = $search->execute("query");
echo "First query found: ", $results->hits, " hits\n";
$results = $search->execute("new OR query");
echo "Second query found: ", $results->hits, " hits\n";
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
First query found: 2 hits
Second query found: 12 hits
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishsearch-resetLimit">
<refnamediv>
<refname>SwishSearch-&gt;resetLimit</refname>
<refpurpose>Reset the search limits</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>void</type><methodname>SwishSearch-&gt;resetLimit</methodname>
<void />
</methodsynopsis>
&warn.experimental.func;
<para>
Reset the search limits previous set by
<xref linkend="function.swishsearch-setLimit" />.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>SwishSearch-&gt;resetLimit</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare();
$results = $search->execute("time");
echo "First query found: ", $results->hits, " hits\n";
$search->setLimit("swishdocsize", "3000", "6000"); //limit by document size, from 3000 to 6000 bytes
$results = $search->execute("time");
echo "Second query found: ", $results->hits, " hits\n";
$search->resetLimit();
$results = $search->execute("time");
echo "Third query found: ", $results->hits, " hits\n";
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
First query found: 5 hits
Second query found: 2 hits
Third query found: 5 hits
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishsearch-setLimit">
<refnamediv>
<refname>SwishSearch-&gt;setLimit</refname>
<refpurpose>Set the search limits</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>void</type><methodname>SwishSearch-&gt;setLimit</methodname>
<methodparam><type>string</type><parameter>property</parameter></methodparam>
<methodparam><type>string</type><parameter>low</parameter></methodparam>
<methodparam><type>string</type><parameter>high</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>property</parameter></term>
<listitem>
<para>
Search result property name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>low</parameter></term>
<listitem>
<para>
The lowest value of the property.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>high</parameter></term>
<listitem>
<para>
The highest value of the property.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
Throws <classname>SwishException</classname> on error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>SwishSearch-&gt;setLimit</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare();
$results = $search->execute("time");
echo "First query found: ", $results->hits, " hits\n";
$i = 0;
while($result = $results->nextResult()) {
echo "Hit #", ++$i, " - ", $result->swishdocsize, " bytes\n";
}
$search->setLimit("swishdocsize", "3000", "6000"); //limit by document size, from 3000 to 6000 bytes
$results = $search->execute("time");
echo "Second query found: ", $results->hits, " hits\n";
$i = 0;
while($result = $results->nextResult()) {
echo "Hit #", ++$i, " - ", $result->swishdocsize, " bytes\n";
}
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
First query found: 5 hits
Hit #1 - 4261 bytes
Hit #2 - 37937 bytes
Hit #3 - 7126 bytes
Hit #4 - 15427 bytes
Hit #5 - 4768 bytes
Second query found: 2 hits
Hit #1 - 4261 bytes
Hit #2 - 4768 bytes
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishsearch-setPhraseDelimiter">
<refnamediv>
<refname>SwishSearch-&gt;setPhraseDelimiter</refname>
<refpurpose>Set the phrase delimiter</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>void</type><methodname>SwishSearch-&gt;setPhraseDelimiter</methodname>
<methodparam><type>string</type><parameter>delimiter</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>delimiter</parameter></term>
<listitem>
<para>
Phrase delimiter character. The default delimiter is double-quotes.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>SwishSearch-&gt;setPhraseDelimiter</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare();
$results = $search->execute('"every time"'); //looking for "every time"
echo "First query found: ", $results->hits, " hits\n";
$search->setPhraseDelimiter("'");
$results = $search->execute("'every time'"); //the same query, but using different delimiter
echo "Second query found: ", $results->hits, " hits\n";
$search->setPhraseDelimiter('"');
$results = $search->execute("'every time'"); //looking for "every" and "time"
echo "Third query found: ", $results->hits, " hits\n";
//let's look at parsed words
var_dump($results->getParsedWords("index.swish-e"));
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
First query found: 1 hits
Second query found: 1 hits
Third query found: 2 hits
array(2) {
[0]=>
string(5) "every"
[1]=>
string(4) "time"
}
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishsearch-setSort">
<refnamediv>
<refname>SwishSearch-&gt;setSort</refname>
<refpurpose>Set the sort order</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>void</type><methodname>SwishSearch-&gt;setSort</methodname>
<methodparam><type>string</type><parameter>sort</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>sort</parameter></term>
<listitem>
<para>
Sort order of the results is a string containing name of a result
property combined with sort direction ("asc" or "desc").
Examples: "swishrank desc", "swishdocpath asc", "swishtitle asc",
"swishdocsize desc", "swishlastmodified desc" etc.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>SwishSearch-&gt;setSort</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare();
$results = $search->execute("time");
echo "First query found: ", $results->hits, " hits\n";
$i = 0;
while($result = $results->nextResult()) {
echo "Hit #", ++$i, " - ", $result->swishdocsize, " bytes\n";
}
$search->setSort("swishdocsize desc"); //sort by document size
$results = $search->execute("time");
echo "Second query found: ", $results->hits, " hits\n";
$i = 0;
while($result = $results->nextResult()) {
echo "Hit #", ++$i, " - ", $result->swishdocsize, " bytes\n";
}
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
First query found: 5 hits
Hit #1 - 4261 bytes
Hit #2 - 37937 bytes
Hit #3 - 7126 bytes
Hit #4 - 15427 bytes
Hit #5 - 4768 bytes
Second query found: 5 hits
Hit #1 - 37937 bytes
Hit #2 - 15427 bytes
Hit #3 - 7126 bytes
Hit #4 - 4768 bytes
Hit #5 - 4261 bytes
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.swishsearch-setStructure">
<refnamediv>
<refname>SwishSearch-&gt;setStructure</refname>
<refpurpose>Set the structure flag in the search object</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>void</type><methodname>SwishSearch-&gt;setStructure</methodname>
<methodparam><type>int</type><parameter>structure</parameter></methodparam>
</methodsynopsis>
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>structure</parameter></term>
<listitem>
<para>
The structure flag a bitmask is used to limit search to certain parts of HTML
documents (like title, meta, body etc.). Its possible values are listed below.
To combine several values use bitwise AND operator, see example below.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
<itemizedlist>
<listitem>
<para>
<constant>SWISH_IN_FILE</constant>
</para>
</listitem>
<listitem>
<para>
<constant>SWISH_IN_TITLE</constant>
</para>
</listitem>
<listitem>
<para>
<constant>SWISH_IN_HEAD</constant>
</para>
</listitem>
<listitem>
<para>
<constant>SWISH_IN_BODY</constant>
</para>
</listitem>
<listitem>
<para>
<constant>SWISH_IN_COMMENTS</constant>
</para>
</listitem>
<listitem>
<para>
<constant>SWISH_IN_HEADER</constant>
</para>
</listitem>
<listitem>
<para>
<constant>SWISH_IN_EMPHASIZED</constant>
</para>
</listitem>
<listitem>
<para>
<constant>SWISH_IN_META</constant>
</para>
</listitem>
</itemizedlist>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Basic <function>SwishSearch-&gt;setStructure</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare();
$results = $search->execute("time");
echo "First query found: ", $results->hits, " hits\n";
$search->setStructure(SWISH_IN_TITLE|SWISH_IN_HEAD); //search in title and head
$results = $search->execute("time");
echo "Second query found: ", $results->hits, " hits\n";
$search->setStructure(SWISH_IN_ALL); //search in whole document, the default value
$results = $search->execute("time");
echo "Third query found: ", $results->hits, " hits\n";
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
]]>
</programlisting>
<para>The above example will output something like this:</para>
<screen>
<![CDATA[
First query found: 5 hits
Second query found: 0 hits
Third query found: 5 hits
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,65 @@
<?xml version = '1.0' encoding = 'iso-8859-1'?>
<!-- $Revision: 1.1 $ -->
<!-- Purpose: -->
<!-- Membership: pecl -->
<reference id="ref.swish" >
<title>Swish-e bindings</title>
<titleabbrev>swish</titleabbrev>
<partintro>
<section id="swish.intro" >
&reftitle.intro;
<para>
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: <ulink url="http://swish-e.org">http://swish-e.org</ulink>.
</para>
&warn.experimental;
</section>
<section id="swish.requirements" >
&reftitle.required;
<para>
PECL/swish requires PHP 5.1.3 or newer.
</para>
</section>
<section id="swish.install" >
&reftitle.install;
<para>
&pecl.info;
<ulink url="&url.pecl.package;swish">&url.pecl.package;swish</ulink>.
</para>
</section>
<section id="swish.configuration">
&reftitle.runtime;
&no.config;
</section>
&reference.swish.constants;
&reference.swish.classes;
</partintro>
&reference.swish.functions;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->