From 50dc9d315ae6127ac424e963245c226789e54206 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 22 Jan 2024 22:56:36 +0200 Subject: [PATCH] add rank field --- src/cli/document/add.php | 10 +++++++++- src/cli/document/crawl.php | 21 +++++++++++---------- src/cli/index/init.php | 4 ++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/cli/document/add.php b/src/cli/document/add.php index 53ae617..b3dfc3b 100644 --- a/src/cli/document/add.php +++ b/src/cli/document/add.php @@ -47,7 +47,15 @@ if ($result->getTotal()) // Add $result = $index->addDocument( [ - 'url' => $url + 'url' => $url, + 'rank' => (int) mb_strlen( + urldecode( + parse_url( + $url, + PHP_URL_PATH + ) + ) + ) ], $crc32url ); diff --git a/src/cli/document/crawl.php b/src/cli/document/crawl.php index 82e1f87..1b008e3 100644 --- a/src/cli/document/crawl.php +++ b/src/cli/document/crawl.php @@ -104,6 +104,7 @@ foreach($index->search('') 'code' => $document->get('code'), 'size' => $document->get('size'), 'mime' => $document->get('mime'), + 'rank' => $document->get('rank'), 'time' => $time ]; @@ -359,15 +360,21 @@ foreach($index->search('') ->get() ->getTotal()) { - echo 'add'; - /* + $index->addDocument( [ - 'url' => $url + 'url' => $url, + 'rank' => (int) mb_strlen( + urldecode( + parse_url( + $url, + PHP_URL_PATH + ) + ) + ) ], $crc32url ); - */ if ($config->cli->document->crawl->debug->level->notice) { @@ -385,16 +392,10 @@ foreach($index->search('') // Replace document data // https://github.com/manticoresoftware/manticoresearch-php/issues/10#issuecomment-612685916 - - // @TODO optimization for replacements required - // https://manual.manticoresearch.com/Data_creation_and_modification/Updating_documents/REPLACE - echo 'replace'; - /* $result = $index->replaceDocument( $data, $document->getId() ); - */ // Debug result if ($config->cli->document->crawl->debug->level->notice) diff --git a/src/cli/index/init.php b/src/cli/index/init.php index e35fd2c..e7d60f3 100644 --- a/src/cli/index/init.php +++ b/src/cli/index/init.php @@ -76,6 +76,10 @@ $result = $index->create( [ 'type' => 'integer' ], + 'rank' => + [ + 'type' => 'integer' + ], 'time' => [ 'type' => 'integer'