init manticore driver

This commit is contained in:
ghost 2024-02-12 14:45:09 +02:00
parent d5d793dfb5
commit a178130500

66
src/Manticore.php Normal file
View 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'
]
]
);
}
}
}