mirror of
https://github.com/php/pecl-search_engine-swish.git
synced 2026-03-24 01:02:07 +01:00
master
README for PHP Swish-e bindings
===============================
$Id$
This extension provides bindings to the swish-e API.
Swish-e is a GPL licensed search engine, with a clause that allows applications
to link against the libswish-e library to use the published API to do so
without invoking the viral portion of the GPL. This is subject to returning a
link back to the swish-e source code.
Here it is:
http://swish-e.org/index.html
How do I use this?
==================
First you need to have built a swish index. Consult the swish docs for details
on that: http://swish-e.org/docs/index.html
% swish-e -i /path/to/stuff/to/index
Now build this PHP module:
% phpize
% configure --with-swish=/usr/local
% make
% su -
# make install
# echo 'extension=swish.so' >> /usr/local/lib/php.ini
Then you can code up an interface to the index using PHP:
<?php
$h = new Swish("index.swish-e");
$results = $h->query("lemons");
echo "There are ", $results->hits, " lemons\n";
while ($r = $results->nextResult()) {
printf("in file %s, relevance %d\n",
$r->swishdocpath,
$r->swishrank
);
}
?>
Brief API reference:
====================
See http://swish-e.org/docs/swish-library.html for more background.
/* major handle class */
class Swish {
public indexes = array(); //indexes and their properties
SwishSearch prepare([string query]);
SwishResult query(string query);
array getMetaList(string indexname);
array getPropertyList(string indexname);
}
/* search handle class */
class SwishSearch {
void setStructure(int structure);
void setPhraseDelimiter(string delimiter_char);
void setSort(string sort_string);
void setLimit(string property, string low, string high);
void resetLimit();
SwishResults execute([string query]);
}
/* search results class */
class SwishResults {
public hits = 0;
public indexes = array();
SwishResult nextResult();
int seekResult(int position);
array getParsedWords(string indexname);
array getRemovedStopWords(string indexname);
}
/* search result class */
class SwishResult {
/*
properties defined by Swish,
automatically "converted" to object properties
*/
array getMetaList();
array stem(string word);
}
vim:ts=2:sw=2:et:
Description
Languages
PHP
50.9%
C
46.6%
M4
2.2%
JavaScript
0.3%