Update test index used by examples/SearchApi.php, a=chris

Chris Pollett [2022-08-15 01:Aug:th]
Update test index used by examples/SearchApi.php, a=chris
Filename
src/examples/0-Archive1421025145.zip
src/examples/IndexData1421025145.zip
src/examples/IndexData1660526790.zip
src/examples/SearchApi.php
src/executables/QueueServer.php
tests/IndexManagerTest.php
diff --git a/src/examples/0-Archive1421025145.zip b/src/examples/0-Archive1421025145.zip
deleted file mode 100644
index e3005fe7e..000000000
Binary files a/src/examples/0-Archive1421025145.zip and /dev/null differ
diff --git a/src/examples/IndexData1421025145.zip b/src/examples/IndexData1421025145.zip
deleted file mode 100644
index cd433e1dc..000000000
Binary files a/src/examples/IndexData1421025145.zip and /dev/null differ
diff --git a/src/examples/IndexData1660526790.zip b/src/examples/IndexData1660526790.zip
new file mode 100644
index 000000000..2a6d1bd9e
Binary files /dev/null and b/src/examples/IndexData1660526790.zip differ
diff --git a/src/examples/SearchApi.php b/src/examples/SearchApi.php
index 01280eb4c..f91541fbf 100644
--- a/src/examples/SearchApi.php
+++ b/src/examples/SearchApi.php
@@ -64,25 +64,19 @@ if (!C\PROFILE) {
  * put a crawl into the WORK_DIRECTORY and that would be used to make the
  * query.
  */
-$archive_timestamp = "1421025145";
-$archive = C\BASE_DIR."/examples/0-Archive$archive_timestamp.zip";
-$index_archive = C\BASE_DIR."/examples/IndexData$archive_timestamp.zip";
-$extract_folder = C\CRAWL_DIR."/cache";
-if (!file_exists($archive) ||
-   !file_exists($index_archive)) {
+$archive_timestamp = "1660526790";
+$index_archive = C\BASE_DIR . "/examples/IndexData$archive_timestamp.zip";
+$extract_folder = C\CRAWL_DIR . "/cache";
+if (!file_exists($index_archive)) {
    echo "\nSearch API test index doesn't exist, so can't run demo\n\n";
    exit();
 }
 if (class_exists("\ZipArchive")) {
     $zip = new \ZipArchive();
-    $zip_h = $zip->open($archive);
-    $zip->extractTo($extract_folder);
-    $zip->close();
     $zip_h = $zip->open($index_archive);
     $zip->extractTo($extract_folder);
     $zip->close();
 } else {
-    exec("unzip $archive -d $extract_folder");
     exec("unzip $index_archive -d $extract_folder");
 }
 // Create a SearchController to do queries with
@@ -93,8 +87,8 @@ $controller = new SearchController();
 echo "\n\n\nAn example of a query request with the search API:\n";
 echo "Total rows numbers are high because by default grouping is done.\n";

-$query = "art i:$archive_timestamp";
-    /* i:1317414322 is the timestamp of the index to use.
+$query = "yioop i:$archive_timestamp";
+    /* i:$archive_timestamp is the timestamp of the index to use.
        API requires that a default index be set even though the query might
        specify to use a different one. The query string we pass to the
        API can be anything you can type into Yioop! search box.
@@ -107,11 +101,12 @@ $data = $controller->queryRequest($query, $num_results,
 outputQueryData($data);

 /*
-   next we do a related search (as our index only has one page in it)
-   the only related page is the page itself
+   next we do a related search (as our index only has two pages in it,
+   seekquarry and yioop) the only related pages to seekquarry.com is yioop.com
+   and seekquarry.com
  */
 echo "\n\n\nAn example of making a related query request with the search API\n";
-$url = "http://www.ucanbuyart.com/";
+$url = "https://www.yioop.com/";
 $num_results = 10; // how many results to get back
 $first_result_to_return = 0;
 $index_timestamp = $archive_timestamp;
@@ -124,10 +119,9 @@ outputQueryData($data);
  */
 echo "\n\n\nAn example of making a cached of page request".
     " with the search API:\n";
-$url = "http://www.ucanbuyart.com/";
+$url = "https://www.seekquarry.com/";
 $ui_flags = [];
-$search_terms = "art classifieds"; // these words will be highlighted
-$index_timestamp = $archive_timestamp;
+$search_terms = "seekquarry"; // these words will be highlighted
 $data = $controller->cacheRequest($url, $ui_flags,
     $search_terms, $index_timestamp);
 echo $data;
@@ -135,7 +129,6 @@ echo $data;
   We now delete the example index to clean-up our test. In real-life
   you wouldn't want to delete your query index after making one query
 */
-unlinkRecursive(C\CRAWL_DIR."/cache/0-Archive$archive_timestamp");
 unlinkRecursive(C\CRAWL_DIR."/cache/IndexData$archive_timestamp");
 // demo over, bye-bye for now!
 exit();
diff --git a/src/executables/QueueServer.php b/src/executables/QueueServer.php
index 36b62c05c..83447ee9a 100644
--- a/src/executables/QueueServer.php
+++ b/src/executables/QueueServer.php
@@ -1772,7 +1772,7 @@ class QueueServer implements CrawlConstants
                     $documents->folder);
             $save_partition = $documents_parameters['SAVE_PARTITION'] ?? 0;
         }
-        L\crawlLog("Advance check details: Last:" .
+        L\crawlLog("Indexer Advance check details: Last:" .
             $this->last_next_partition_to_add . " Next:" .
             $next_partition_to_add . " Save:" . $save_partition);
         /* first condition below is to ensure not to call if still processing
@@ -1785,7 +1785,7 @@ class QueueServer implements CrawlConstants
             $this->last_next_partition_to_add = $next_partition_to_add;
             $this->start_dictionary_time = $time;
             $options = "run {$this->channel} '$bundle_name'";
-            L\crawlLog("Exec'ing DictionaryUpdater with parameters: " .
+            L\crawlLog("Indexer Exec'ing DictionaryUpdater with parameters: " .
                 $options);
             CrawlDaemon::execScriptInOwnProcess(C\BASE_DIR .
                 "/executables/DictionaryUpdater.php", $options);
diff --git a/tests/IndexManagerTest.php b/tests/IndexManagerTest.php
index daea12d8a..9160524c2 100644
--- a/tests/IndexManagerTest.php
+++ b/tests/IndexManagerTest.php
@@ -69,14 +69,6 @@ use seekquarry\yioop\library\UnitTest;
         if (!file_exists(self::TEST_DIR)) {
             mkdir(self::TEST_DIR);
         }
-        if (!file_exists(self::TEST_DIR . "/$old_bundle")) {
-            $zip_archive = new \ZipArchive();
-            $success =
-                $zip_archive->open(C\BASE_DIR . "/examples/$old_bundle.zip");
-            if ($success) {
-                $zip_archive->extractTo(self::TEST_DIR);
-            }
-        }
         $this->index_archive = new IndexDocumentBundle(self::TEST_DIR .
             "/$new_bundle", false, "TestBundle", 3, 5);
     }
@@ -94,9 +86,6 @@ use seekquarry\yioop\library\UnitTest;
      */
     public function getIndexTestCase()
     {
-        $old_index = IndexManager::getIndex(self::TEST_DIR . "/".
-            self::OLD_BUNDLE);
-        $this->assertTrue($old_index, "Get existing old bundle not null");
         $new_index = IndexManager::getIndex(self::TEST_DIR . "/".
             self::NEW_BUNDLE);
         $this->assertTrue($new_index, "Get existing new bundle not null");
@@ -107,11 +96,8 @@ use seekquarry\yioop\library\UnitTest;
      */
     public function getVersionTestCase()
     {
-        $version_old = IndexManager::getVersion(self::TEST_DIR . "/".
-            self::OLD_BUNDLE);
         $version_new = IndexManager::getVersion(self::TEST_DIR . "/".
             self::NEW_BUNDLE);
-        $this->assertEqual($version_old, "1", "Version 1 index detected");
         $this->assertEqual($version_new, "3.2", "Version 3.2 index detected");
     }
     /**
ViewGit