Code Monkey home page Code Monkey logo

pecl-search_engine-swish's Introduction

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:

pecl-search_engine-swish's People

Contributors

pierrejoye avatar tony2001 avatar tyrael avatar wez avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.