2017 © Pedro Peláez
 

library search-engine

Search engine for ORM based on Zend Lucene.

image

nqxcode/search-engine

Search engine for ORM based on Zend Lucene.

  • Sunday, July 27, 2014
  • by nqxcode
  • Repository
  • 1 Watchers
  • 1 Stars
  • 65 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Search engine for ORM based on Zend Lucene

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Search engine gives opportunity of indexing of models (ActiveRecord) on demanded fields. Search engine uses the morphological filter for english and russian words. Morphological filter based on "phpMorphy" (morphological analyzer library)., (*2)

In order that the model was available to indexation, it is necessary:, (*3)

  1. Add name of class of model to list of model classes at initialization search engine.
  2. Declare model with ISearchable interface;

Usage

Initialization on search engine

$searchEngine = new SearchEngine\Engine('Product', $indexDirectory); // $indexDirectory path to index directory

Declare model with ISearchable interface

use SearchEngine\ISearchable;

class Product implements ISearchable
{
    // TODO ...
}

Example of realization getAttributesForIndexing method of ISearchable interface

use SearchEngine\ISearchable;

class Product implements ISearchable
{
    // ...

    public funtion getAttributesForIndexing()
    {
        // list of couples "field name - field value"
        return array(
            new Attribute('fieldName', $this->fieldName),
            new Attribute('otherFieldName', $this->otherFieldName)
        );
    }
}

Operation on index

Full update for search index

$searchEngine->fullUpdateIndex();

Update index for ISearchable model

$searchEngine->updateIndex($model);

Delete index for ISearchable model

$searchEngine->deleteIndex($model);

Execute search query

/**
 * @var ZendSearch\Lucene\Search\QueryHit[] $hits
 */
$queryHits = $searchEngine->search($query);

Get result for paginator

/**
 * @var SearchEngine\Result\Hit[] $hits
 */
$hits = $searchEngine->parseHitsByRange($queryHits, $elementsPerPage, $currentPage);

// get the found ISearchable model from each $hit
foreach ($hits as $hit):
    $model = $hit->getItem();
}

Get full result

/**
 * @var SearchEngine\Result\Hit[] $hits
 */
$hits = $searchEngine->parseHits($queryHits);

// get the found ISearchable model from each $hit
foreach ($hits as $hit):
    $model = $hit->getItem();
}

License

Search engine licenced under the MIT license., (*4)

The Versions

27/07 2014

dev-master

9999999-dev

Search engine for ORM based on Zend Lucene.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Pokoev

orm search lucene

27/07 2014

v1.0.6

1.0.6.0

Search engine for ORM based on Zend Lucene.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andrey Pokoev

orm search lucene

04/03 2014

v1.0.5

1.0.5.0

search engine based on zend lucene

  Sources   Download

The Requires

 

by Andrey Pokoev

04/03 2014

v1.0.4

1.0.4.0

search engine based on zend lucene

  Sources   Download

The Requires

 

by Andrey Pokoev

25/02 2014

v1.0.3

1.0.3.0

search engine based on zend lucene

  Sources   Download

The Requires

 

by Andrey Pokoev

25/02 2014

v1.0.2

1.0.2.0

search engine based on zend lucene

  Sources   Download

The Requires

 

by Andrey Pokoev

25/02 2014

v1.0.0

1.0.0.0

search engine based on zend lucene

  Sources   Download

The Requires

 

by Andrey Pokoev

25/02 2014

v1.0.1

1.0.1.0

search engine based on zend lucene

  Sources   Download

The Requires

 

by Andrey Pokoev