php-doc-en/reference/swish/functions/swishsearch-setsort.xml
Nilgün Belma Bugüner fa8878d2a5 fixed properties
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@283840 c90b9560-bf6c-de11-be94-00142212c4b1
2009-07-11 09:13:17 +00:00

120 lines
2.9 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<refentry xml:id="function.swishsearch-setsort" xmlns="http://docbook.org/ns/docbook">
<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="returnvalues">
&reftitle.returnvalues;
<para>
&return.void;
</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>
&example.outputs.similar;
<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
-->