承接 nqxcode/search-engine 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nqxcode/search-engine

Composer 安装命令:

composer require nqxcode/search-engine

包简介

Search engine for ORM based on Zend Lucene.

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

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

In order that the model was available to indexation, it is necessary:

  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.

统计信息

  • 总下载量: 79
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-10-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固