mirror of
https://github.com/kvazar-network/index-php.git
synced 2025-02-02 02:04:24 +00:00
init manticore driver
This commit is contained in:
parent
d5d793dfb5
commit
a178130500
66
src/Manticore.php
Normal file
66
src/Manticore.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Kvazar\Index;
|
||||||
|
|
||||||
|
class Manticore
|
||||||
|
{
|
||||||
|
private \Manticoresearch\Client $_client;
|
||||||
|
|
||||||
|
private $_index;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
?string $name = 'kvazar',
|
||||||
|
?string $host = '127.0.0.1',
|
||||||
|
?int $port = 9308,
|
||||||
|
?bool $drop = false
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->_client = new \Manticoresearch\Client(
|
||||||
|
[
|
||||||
|
'host' => $host,
|
||||||
|
'port' => $port,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->_index = $this->_client->index(
|
||||||
|
$name
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($drop)
|
||||||
|
{
|
||||||
|
$this->_index->drop(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->_index->status())
|
||||||
|
{
|
||||||
|
$this->_index->create(
|
||||||
|
[
|
||||||
|
'block' =>
|
||||||
|
[
|
||||||
|
'type' => 'int'
|
||||||
|
],
|
||||||
|
'namespace' =>
|
||||||
|
[
|
||||||
|
'type' => 'text'
|
||||||
|
],
|
||||||
|
'txid' =>
|
||||||
|
[
|
||||||
|
'type' => 'text'
|
||||||
|
],
|
||||||
|
'key' =>
|
||||||
|
[
|
||||||
|
'type' => 'text'
|
||||||
|
],
|
||||||
|
'value' =>
|
||||||
|
[
|
||||||
|
'type' => 'text'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user