manticoresoftware/manticoresearch-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

manticoresoftware/manticoresearch-php

Composer 安装命令:

composer require manticoresoftware/manticoresearch-php

包简介

PHP Client for Manticore Search

README 文档

README

Build Status Scrutinizer Code Quality codecov.io Latest Stable Version License Slack

Total Downloads Monthly Downloads Daily Downloads composer.lock

GitHub Code Size GitHub Repo Size GitHub Last Commit GitHub Activity GitHub Issues

Official PHP client for Manticore Search.

❗ WARNING: this is a development version of the client. The latest release's readme is https://github.com/manticoresoftware/manticoresearch-php/tree/4.0.1

Features

  • One to one mapping with the HTTP API
  • connection pools with pluggable selection strategy. Defaults to static round robin
  • pluggable PSR/Log interface
  • pluggable transport protocols.
  • persistent connections

Requirements

Requires PHP 7.1 or greater with the native JSON extension. Default transport handler uses the cURL extension.

Minimum Manticore Search version is 2.5.1 with HTTP protocol enabled.

Manticore Search manticoresearch-php PHP
>= 7.0.0 4.0.x >= 7.4, >=8.0
>= 6.3.6 3.2.x >= 7.4, >=8.0
>= 6.2.0 3.1.x >= 7.4, >=8.0
>= 6.2.0 3.0.x >= 7.4, >=8.0
>= 6.0.4 3.0.x >= 7.1, >=8.0
>= 4.2.1 2.0.x, 2.1.x, 2.2.x >= 7.1, >=8.0
>= 4.0.2 1.7.x, 1.8.x >= 7.1, >=8.0
>= 3.5.2 1.6.x >= 7.1, >=8.0
>= 3.5.0 1.5.x >= 7.1, <8.0
>= 3.5.0 1.4 >= 7.1, <8.0
<= 3.4.x 1.3 >= 7.1, <8.0
>= 2.5.1, <3.4.0 1.2 >= 7.1, <8.0

Documentation

Full documentation is available in docs folder.

Manticore Search server documentation: https://manual.manticoresearch.com/.

Getting Started

Install the Manticore Search PHP client using composer package manager:

composer require manticoresoftware/manticoresearch-php:dev-master

Initiate a table:

require_once __DIR__ . '/vendor/autoload.php';

$config = ['host'=>'127.0.0.1','port'=>9308];
$client = new \Manticoresearch\Client($config);
$table = $client->table('movies');

Create the table:

$table->create([
    'title'=>['type'=>'text'],
    'plot'=>['type'=>'text'],
    '_year'=>['type'=>'integer'],
    'rating'=>['type'=>'float']
    ]);

Add a document:

$table->addDocument([
        'title' => 'Star Trek: Nemesis',
        'plot' => 'The Enterprise is diverted to the Romulan homeworld Romulus, supposedly because they want to negotiate a peace treaty. Captain Picard and his crew discover a serious threat to the Federation once Praetor Shinzon plans to attack Earth.',
        '_year' => 2002,
        'rating' => 6.4
        ],
    1);

Add several documents at once:

$table->addDocuments([
        ['id'=>2,'title'=>'Interstellar','plot'=>'A team of explorers travel through a wormhole in space in an attempt to ensure humanity\'s survival.','_year'=>2014,'rating'=>8.5],
        ['id'=>3,'title'=>'Inception','plot'=>'A thief who steals corporate secrets through the use of dream-sharing technology is given the inverse task of planting an idea into the mind of a C.E.O.','_year'=>2010,'rating'=>8.8],
        ['id'=>4,'title'=>'1917 ','plot'=>' As a regiment assembles to wage war deep in enemy territory, two soldiers are assigned to race against time and deliver a message that will stop 1,600 men from walking straight into a deadly trap.','_year'=>2018,'rating'=>8.4],
        ['id'=>5,'title'=>'Alien','plot'=>' After a space merchant vessel receives an unknown transmission as a distress call, one of the team\'s member is attacked by a mysterious life form and they soon realize that its life cycle has merely begun.','_year'=>1979,'rating'=>8.4]
    ]); 

Perform a search:

$results = $table->search('space team')->get();

foreach($results as $doc) {
   echo 'Document:'.$doc->getId()."\n";
   foreach($doc->getData() as $field=>$value)
   {   
        echo $field.": ".$value."\n";
   }
}

Result:

Document:2
year: 2014
rating: 8.5
title: Interstellar
plot: A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival.

A text search with attribute filters:

$results = $table->search('space team')
                 ->filter('_year','gte',2000)
                 ->filter('rating','gte',8.0)
                 ->sort('_year','desc')
                 ->get();

foreach($results as $doc) {
    echo 'Document:'.$doc->getId()."\n";
    foreach($doc->getData() as $field=>$value)
    {   
        echo $field.": ".$value."\n";
    }
}

Update documents:

By document id:

$table->updateDocument(['_year'=>2019],4);

By query:

$table->updateDocument(['_year'=>2019],['match'=>['*'=>'team']]);

Get table schema:

$table->describe();

Drop table:

$table->drop();

The above will fail if the table does not exist. To get around this pass a parameter of true, which cause the failure to be silent.

$table->drop(true);

License

Manticore Search PHP Client is an open-source software licensed under the MIT license

manticoresoftware/manticoresearch-php 适用场景与选型建议

manticoresoftware/manticoresearch-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 627.05k 次下载、GitHub Stars 达 207, 最近一次更新时间为 2020 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 manticoresoftware/manticoresearch-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 627.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 208
  • 点击次数: 12
  • 依赖项目数: 18
  • 推荐数: 0

GitHub 信息

  • Stars: 207
  • Watchers: 13
  • Forks: 37
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-30