承接 byng/pimcore-elasticsearch-plugin 相关项目开发

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

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

byng/pimcore-elasticsearch-plugin

Composer 安装命令:

composer require byng/pimcore-elasticsearch-plugin

包简介

Elasticsearch Pimcore plugin

README 文档

README

The Elasticsearch plugin for Pimcore Saves/updates contents (text only) of document's (editables) and assets to Elasticsearch. It also provides a query builder to search the index.

Features

  • Automatic indexing of documents and assets to Elasticsearch when created/updated in Pimcore admin.
  • Hooks to add custom properties to the index.
  • A simple query builder to retrieve indexed documents. Supports querying, filtering, sorting and pagination.

System Requirements

  • PHP - 5.6+
  • Elasticsearch - 1.7+
  • Pimcore - 3, 4 (not tested on 5 yet)

Installation via composer

The recommended method to install the Pimcore Elasticsearch Plugin is via Composer.

1 - Add byng/pimcore-elasticsearch-plugin as a dependency in your project's composer.json file and run composer install

2 - Copy the distribution config file (elasticsearchplugin.xml.dist) in the root of the plugin folder to {PIMCORE_WEBSITE_DIR}/var/config/elasticsearchplugin.xml.

3 - Enable the plugin in Pimcore using the extension manager.

Quickstart

Once the installation has been completed, the first time you create or update a document the Elasticsearch index will be created and the document will be indexed. You can verify that the index exists using curl or Kibana.

Hooks

Hooks allow you to hook into the plugin at various points to provide additional functionality. It uses the standard Zend EventManager which Pimcore uses.

Registering an event listener example

For example to register an even listener:

// @var $eventManager Zend_EventManager_EventManager
$eventManager->attach(
    "document.elasticsearch.preIndex",
    [__CLASS__, "handlePreIndex"]
);

The above code will call the handlePreIndex() method of the class where it was added whenever a document is ready to be indexed.

Within the handlePreIndex() method you have access to the actual Pimcore document which is being indexed and also the data the plugin has lready extracted. You can add additional properties to the parameters array and they will also be saved to the index:

public static function handlePreIndex(ZendEvent $event)
{
    /** @var Page $document */
    $document = $event->getTarget();
    $params = $event->getParams();

    $params["body"]["page"]["customProperty"] = "something";
}

Available hooks

The following hooks are currently available:

document.elasticsearch.preIndex

This hook is called after the plugin has extracted all the information from the document to index and before it writes the data to Elasticsearch. You can use this hook to write additional/custom properties to the index.

asset.elasticsearch.preIndex

This hook is the asset equivalent of "document.elasticsearch.preIndex".

Querying

The pluigin provides a simple query builder to make it easy to extract information from Elasticsearch.

Example

use Byng\Pimcore\Elasticsearch\Query\BoolQuery;
use Byng\Pimcore\Elasticsearch\Query\MatchQuery;
use Byng\Pimcore\Elasticsearch\Query\Query;
use Byng\Pimcore\Elasticsearch\Query\QueryBuilder;
use Byng\Pimcore\Elasticsearch\Gateway\PageGateway;

$boolQuery = new BoolQuery();
$boolQuery->addMust(new MatchQuery("_all", "something"));

$query = new Query($boolQuery);

$queryBuilder = new QueryBuilder();
$queryBuilder->setQuery($query);
$queryBuilder->setSize(10); // number of results to return

$pageGateway = PageGateway::getInstance();
$resultSet =  $pageGateway->query($queryBuilder);

The following JSON request will be generated from the above code and sent to Elasticsearch:

{
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "_all": "something"
                    }
                }
            ]
        }
    },
    "size": 10
}

This will retrieve all documents that contain the word "something".

Todo

  • Provide more complete query documentation
  • Add support for custom queries, i.e. an array which can be converted to json and posted to Elasticsearch without any processing if the plugin doesn't support the whole Elasticsearch DSL for querying.

License

MIT

byng/pimcore-elasticsearch-plugin 适用场景与选型建议

byng/pimcore-elasticsearch-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.29k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2016 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「plugin」 「elasticsearch」 「pimcore」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 byng/pimcore-elasticsearch-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 byng/pimcore-elasticsearch-plugin 我们能提供哪些服务?
定制开发 / 二次开发

基于 byng/pimcore-elasticsearch-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 11
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-17