Merge branch 'MDL-53271-master' of git://github.com/merrill-oakland/moodle
[moodle.git] / search / engine / solr / classes / engine.php
index f7e6cb6..e18b31e 100644 (file)
@@ -321,17 +321,33 @@ class engine extends \core_search\engine {
      *
      * @return void
      */
-    public function commit() {
+    protected function commit() {
         $this->get_search_client()->commit();
     }
 
+    /**
+     * Do any area cleanup needed, and do anything to confirm contents.
+     *
+     * Return false to prevent the search area completed time and stats from being updated.
+     *
+     * @param \core_search\area\base $searcharea The search area that was complete
+     * @param int $numdocs The number of documents that were added to the index
+     * @param bool $fullindex True if a full index is being performed
+     * @return bool True means that data is considered indexed
+     */
+    public function area_index_complete($searcharea, $numdocs = 0, $fullindex = false) {
+        $this->commit();
+
+        return true;
+    }
+
     /**
      * Defragments the index.
      *
      * @return void
      */
     public function optimize() {
-        $this->get_search_client()->optimize();
+        $this->get_search_client()->optimize(1, true, false);
     }
 
     /**
@@ -342,6 +358,7 @@ class engine extends \core_search\engine {
      */
     public function delete_by_id($id) {
         $this->get_search_client()->deleteById($id);
+        $this->commit();
     }
 
     /**
@@ -356,6 +373,7 @@ class engine extends \core_search\engine {
         } else {
             $this->get_search_client()->deleteByQuery('*:*');
         }
+        $this->commit();
     }
 
     /**
@@ -428,6 +446,7 @@ class engine extends \core_search\engine {
             'ssl_password' => !empty($this->config->ssl_keypassword) ? $this->config->ssl_keypassword : '',
             'ssl_cainfo' => !empty($this->config->ssl_cainfo) ? $this->config->ssl_cainfo : '',
             'ssl_capath' => !empty($this->config->ssl_capath) ? $this->config->ssl_capath : '',
+            'timeout' => !empty($this->config->server_timeout) ? $this->config->server_timeout : '30'
         );
 
         $this->client = new \SolrClient($options);