h69/content-mapping-adapter-elasticsearch

此包已被废弃且不再维护。未建议替代包。

为h69/content-mapping迷你框架中的elasticsearch-php客户端提供的适配器。

1.0.0 2016-09-03 15:37 UTC

This package is auto-updated.

Last update: 2023-01-21 16:04:27 UTC


README

Build Status Coverage Status

h69/content-mapping迷你框架中的elasticsearch-php客户端提供的适配器。

安装

composer require h69/content-mapping-adapter-elasticsearch

使用方法

use Elasticsearch\ClientBuilder;
use H69\ContentMapping\Synchronizer;
use H69\ContentMapping\Elasticsearch\Adapter as ElasticsearchAdapter;

$elasticsearchClient = ClientBuilder::create()->build();
$elasticsearchIndex = 'myIndex';

$sourceAdapter = ...;
$destinationAdapter = new ElasticsearchAdapter($elasticsearchClient, $elasticsearchIndex);
$typeToSynchronize = 'pages';

$synchronizer = new Synchronizer($sourceAdapter, $destinationAdapter);
$synchronizer->synchronize($typeToSynchronize, function($objectA, $objectB){
    ...
    //return Result::unchanged();
    return Result::changed($updatedObjectB);
});

致谢、版权和许可证

此项目/副本由h69于2016年开始并开发。代码在MIT许可证下发布。