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: » http://swish-e.org.
Ce module est EXPERIMENTAL. Cela signifie que le comportement de ces fonctions, leurs noms et, concrètement, TOUT ce qui est documenté ici peut changer dans un futur proche, SANS PREAVIS ! Soyez-en conscient, et utilisez ce module à vos risques et périls.
PECL/swish requires PHP 5.1.3 or newer.
Des informations sur l'installation de ces extensions PECL peuvent être trouvées dans le chapitre du manuel intitulé Installation des extensions PECL. D'autres informations comme les notes sur les nouvelles versions, les téléchargements, les sources des fichiers, les informations concernant les mainteneurs ainsi qu'un CHANGELOG, peuvent être trouvées ici : » http://pecl.php.net/package/swish.
The latest PECL/swish Win32 DLL can be downloaded here: » php_swish.dll.
Cette extension ne définit aucune directive de configuration.
Exemple 2682. Basic search query
<?php
try {
$swish = new Swish("index.swish-e");
$results = $swish->query("test OR text");
echo "Found ", $results->hits, " results\n";
while ($result = $results->nextResult()) {
var_dump($result);
break; //break after the first result
}
} catch (SwishException $e) {
echo "Error: ", $e->getMessage(), "\n";
}
?>
L'exemple ci-dessus va afficher quelque chose de similaire à :
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) }
Ces constantes sont définies par cette extension, et ne sont disponibles que si cette extension a été compilée avec PHP, ou bien chargée au moment de l'exécution.
indexes - the array of indexes used and their properties. Certain list of properties depends on Swish-e version.
Swish::__construct - constructs new
Swish
object.
Throws SwishException
on error.
Swish->prepare - prepares and returns
SwishSearch
object.
Throws SwishException
on error.
Swish->query - executes the query and
returns SwishResults
object.
Throws SwishException
on error.
Swish->getMetaList - returns an array of meta entries for the given index file.
Swish->getPropertyList - returns an array of properties for the given index file.
SwishSearch->setStructure - sets the structure flag in the search object. This flag is used to limit search to certain parts of HTML documents.
SwishSearch->setPhraseDelimiter - sets the phrase delimiter character. The default delimiter is double-quotes.
SwishSearch->setSort - sets the sort order of the results.
SwishSearch->setLimit - sets the limits
for the search.
Throws SwishException
on error.
SwishSearch->resetLimit - resets the limits.
SwishSearch->execute - executes the
query and returns SwishResults
object.
Throws SwishException
on error.
hits - the number of results in this
SwishResults
object.
indexes - the array of indexes used in the search.
SwishResults->nextResult - returns
next SwishResult
object or FALSE if no
more results are available.
SwishResults->seekResult - sets the
current seek position in the SwishResults
object.
Throws SwishException
on error.
SwishResults->getParsedWords - returns an array of words in the query with stopwords removed.
SwishResults->getRemovedStopwords - returns an array of removed stopwords.
SwishResult->getMetaList - returns an array of meta entries for the index used in this result.
SwishResult->stem - stems the word
and returns result as an array of strings.
Throws SwishException
on error.
SwishException
extends the built in
Exception
class and possesses the same set of
properties and methods. See la section intitulée « Exceptions étendues » for more details.