initial commit

This commit is contained in:
ghost 2023-11-19 23:00:51 +02:00
parent a5fabf2381
commit 7dfc800a67
9 changed files with 583 additions and 2 deletions

57
src/cli/document/add.php Normal file
View file

@ -0,0 +1,57 @@
<?php
// Load dependencies
require_once __DIR__ . '/../../../vendor/autoload.php';
// Init config
$config = json_decode(
file_get_contents(
__DIR__ . '/../../config.json'
)
);
// Init
$client = new \Manticoresearch\Client(
[
'host' => $config->manticore->server->host,
'port' => $config->manticore->server->port,
]
);
// Init index
$index = $client->index(
$config->manticore->index->document
);
// Check URL for exist
$result = $index->search('@url "' . $argv[1] . '"')
->limit(1)
->get();
if ($result->getTotal())
{
echo sprintf(
'URL "%s" already exists in "%s" index!' . PHP_EOL,
$argv[1],
$config->manticore->index->document
);
exit;
}
// Add
$result = $index->addDocument(
[
'url' => $argv[1]
]
);
echo sprintf(
'URL "%s" added to "%s" index: %s' . PHP_EOL,
$argv[1],
$config->manticore->index->document,
print_r(
$result,
true
)
);