2017 © Pedro PelĂĄez
 

library simple-search

Simple Search Engine in PHP

image

markusos/simple-search

Simple Search Engine in PHP

  • Wednesday, March 29, 2017
  • by markusos
  • Repository
  • 3 Watchers
  • 7 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 40 % Grown

The README.md

Simple Search

Code Climate Test Coverage Build Status License, (*1)

A Simple Search Engine in PHP, (*2)

  • Query the document index using multi word queries.
  • Search result is ranked with TF-IDF term weighting and cosine similarity.
  • Uses MongoDB, MySQL or SQLite to store the documents.
  • Stores the search index in Memcached or MongoDB.
  • Easily extensible to support other storage providers.
  • Uses Snowball- or Porter-stemming of tokens.

NOTE: this project is still in development, (*3)

Install

``` 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');

Custom setup

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);

Testing

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

License

The MIT License (MIT), (*12)

Copyright (c) 2015 Markus Östberg, (*13)

The Versions

29/03 2017

dev-master

9999999-dev https://github.com/markusos/simple-search

Simple Search Engine in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

search search engine