• Stars
    star
    152
  • Rank 236,255 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 4 years ago
  • Updated 29 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Official PHP client for Manticore Search

manticoresearch-php

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/3.1.0

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
>= 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

Initiate an index:

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

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

Create the index:

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

Add a document:

$index->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:

$index->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]
    ]); 
$results = $index->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 = $index->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:

$index->updateDocument(['year'=>2019],4);

By query:

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

Get index schema:

$index->describe();

Drop index:

$index->drop();

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

$index->drop(true);

License

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

More Repositories

1

manticoresearch

Easy to use open source fast database for search | Good alternative to Elasticsearch now | Drop-in replacement for E in the ELK soon
C++
8,226
star
2

columnar

Manticore Columnar Library
C++
74
star
3

docker

Official docker for Manticore Search
Shell
59
star
4

go-sdk

Go client for Manticore Search
Go
53
star
5

manticoresearch-java

Official Java client for Manticore Search
Java
35
star
6

manticoresearch-net

Official .NET client for Manticore Search
C#
33
star
7

manticoresearch-javascript

Official Javascript client for Manticore Search
JavaScript
32
star
8

manticoresearch-python

Official Python client for Manticore Search
Python
32
star
9

manticoresearch-helm

Helm chart for Manticore Search
PHP
29
star
10

manticoresearch-buddy

Manticore Buddy is a Manticore Search's sidecar which helps it with various tasks
PHP
18
star
11

manticoresearch-elixir

Official Elixir client for Manticore Search
Elixir
15
star
12

manticoresearch-go

Official Go client for Manticore Search
Shell
15
star
13

es2ms

Elasticsearch -> Manticore Search data migration tool
PHP
8
star
14

manticoresearch-typescript

Official TypeScript client for Manticore Search
TypeScript
6
star
15

plugins

Plugins and user defined function (UDFs) for Manticore Search
C
5
star
16

manticoresearch-prometheus

PHP
5
star
17

lemmatizer-uk

UK lemmatizer for Manticore Search
C
4
star
18

clt

Command Line Tester
Rust
4
star
19

demos

Collection of code samples showing how to implement some Manticore Search features
PHP
4
star
20

benchmarks

automated benchmarks of Manticore vs different technologies
Shell
3
star
21

openapi

Manticore Search clients generator
Mustache
3
star
22

executor

Custom build of PHP used by Manticore
Shell
3
star
23

homebrew-tap-old

The official Manticore Search Homebrew Tap
Ruby
3
star
24

manticoresearch-backup

Repository for Manticore Search backup scripts
PHP
3
star
25

buddy-core

Manticore Buddy plugins core
PHP
1
star
26

phar_builder

Tools to build executor-related php projects
Dockerfile
1
star
27

manticore-github-issue-search

Demo: GitHub search with Manticore Search
PHP
1
star
28

buddy-plugin-create-table

The Buddy create sharded table plugin
PHP
1
star