dev-master
9999999-dev https://github.com/markusos/simple-searchSimple Search Engine in PHP
MIT
The Requires
- php >=5.4.0
- camspiers/porter-stemmer 1.0.0
The Development Requires
search search engine
Wallogit.com
2017 © Pedro PelĂĄez
Simple Search Engine in PHP
A Simple Search Engine in PHP, (*2)
NOTE: this project is still in development, (*3)
``` bash $ composer require markusos/simple-search dev-master, (*4)
When running the Search Engine make sure that the MongoDB and Memcached processes are running on the server. ### System Requirements You need **PHP >= 5.4.0** to use `markusos\simple-search` but the latest stable version of PHP is recommended. If you want to use the MongoDB storage and/or index providers, you need to install the `mongo` extension. ``` bash $ pecl install mongo
To use the snowball stemmer you also need to install the stem extension., (*5)
``` bash $ pecl install stem, (*6)
Make sure that you install the languages that you need when installing the `stem` extension. ### Usage #### Basic usage **Index document:** ```php <?php $document = new Search\Document( 'Test Title', 'This is a test document with some content to be searchable.' ); $engine = new Search\Engine(); $engine->addDocument($document);
Search:, (*7)
<?php
$engine = new Search\Engine();
$result = $engine->search('test document');
The search engine supports customization by exchangeable service providers. When initializing the search engine it is possible to switch out the default implementations and provide your own., (*8)
<?php
$config = Search\Config\Config::createBuilder()
->tokenizer($tokenizer)
->store($store)
->index($index)
->ranker($ranker)
->stopWords($stopWords)
->build();
$engine = new Search\Engine($config);
Or you can use the default and override the settings you need:, (*9)
<?php
$config = Search\Config\Config::createBuilder()
->defaultConfig()
->stopWords(['new', 'list', 'of', 'stop', 'words'])
->build();
$engine = new Search\Engine($config);
Simple Search has a PHPUnit test suite. To run the tests, run the following command from the project folder:, (*10)
``` bash $ phpunit, (*11)
If you don't want to run the integration tests that require Memcached and MongoDB to be started, simply run: ``` bash $ phpunit --testsuite unit
The MIT License (MIT), (*12)
Copyright (c) 2015 Markus Ăstberg, (*13)
Simple Search Engine in PHP
MIT
search search engine