mirror of
https://github.com/YGGverse/Yo.git
synced 2026-04-01 02:05:29 +00:00
initial commit
This commit is contained in:
parent
a5fabf2381
commit
7dfc800a67
9 changed files with 583 additions and 2 deletions
57
src/cli/document/add.php
Normal file
57
src/cli/document/add.php
Normal 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
|
||||
)
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue