CLXI. Swish-e bindings
Wstę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: https://swish-e.org.
Ostrzeżenie |
Ten moduł jest w stadium EKSPERYMENTALNYM. Oznacza to, że zachowanie tych funkcji, ich nazwy, w zasadzie wszystko udokumentowane tutaj może zostać zmienione w przyszłych wersjach PHP bez wcześniejszego uprzedzenia. Używaj tego modułu na własne ryzyko. |
Wymagania
PECL/swish requires PHP 5.1.3 or newer.
Instalacja
Informacje na temat instalacji tego rozszerzenia PECL można znaleźć w podręczniku w rozdziale zatytułowanym Instalacja rozszerzeń PECL. Dodatkowe informacje, takie jak nowe wersje, pliki do pobrania, pliki źródłowe, informacje o opiekunach czy rejestr zmian, można znaleźć tutaj: https://pecl.php.net/package/swish.
Konfiguracja uruchomieniowa
To rozszerzenie nie definiuje posiada żadnych dyrektyw konfiguracyjnych w pliku php.ini.
Przykłady
Powyższy przykład wyświetli coś podobnego do:
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) } |
Stałe predefiniowane
Poniższe stałe są zdefiniowane w tym rozszerzeniu i stają się dostępne, gdy rozszerzenie jest dokompilowane do PHP, lub załadowane dynamicznie przy starcie.
- Swish::META_TYPE_UNDEF (integer)
- Swish::META_TYPE_STRING (integer)
- Swish::META_TYPE_ULONG (integer)
- Swish::META_TYPE_DATE (integer)
- Swish::IN_FILE_BIT (integer)
- Swish::IN_TITLE_BIT (integer)
- Swish::IN_HEAD_BIT (integer)
- Swish::IN_BODY_BIT (integer)
- Swish::IN_COMMENTS_BIT (integer)
- Swish::IN_HEADER_BIT (integer)
- Swish::IN_EMPHASIZED_BIT (integer)
- Swish::IN_META_BIT (integer)
- Swish::IN_FILE (integer)
- Swish::IN_TITLE (integer)
- Swish::IN_HEAD (integer)
- Swish::IN_BODY (integer)
- Swish::IN_COMMENTS (integer)
- Swish::IN_HEADER (integer)
- Swish::IN_EMPHASIZED (integer)
- Swish::IN_META (integer)
- Swish::IN_ALL (integer)
Klasy predefiniowane
Klasy predefiniowane
Swish
Właściwości
indexes - the array of indexes used and their properties. Certain list of properties depends on Swish-e version.
Metody
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
Metody
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.
SwishResults
Właściwości
hits - the number of results in this SwishResults object.
indexes - the array of indexes used in the search.
Metody
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
Właściwości
Properties list depends on Swish-e version, see examples.
Metody
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
SwishException extends the build in Exception class and possesses the same set of properties and methods. See sekcja Extending Exceptions w Rozdział 20 for more details.
- Spis treści
- Swish::__construct -- Construct a Swish object
- Swish->getMetaList -- Get the list of meta entries for the index
- Swish->getPropertyList -- Get the list of properties for the index
- Swish->prepare -- Prepare a search query
- Swish->query -- Execute a query and return results object
- SwishResult->getMetaList -- Get a list of meta entries
- SwishResult->stem -- Stems the given word
- SwishResults->getParsedWords -- Get an array of parsed words
- SwishResults->getRemovedStopwords -- Get an array of stopwords removed from the query
- SwishResults->nextResult -- Get the next search result
- SwishResults->seekResult -- Set current seek pointer to the given position
- SwishSearch->execute -- Execute the search and get the results
- SwishSearch->resetLimit -- Reset the search limits
- SwishSearch->setLimit -- Set the search limits
- SwishSearch->setPhraseDelimiter -- Set the phrase delimiter
- SwishSearch->setSort -- Set the sort order
- SwishSearch->setStructure -- Set the structure flag in the search object