/**
 * Configure the index to exclude unpublished nodes.
 */
function osha_configure_search_index()
{
    if ($index = search_api_index_load('default_multilingual_node_index')) {
        $index->options['data_alter_callbacks']['search_api_alter_node_status']['status'] = 1;
        $index->save();
        $index->reindex();
        drupal_set_message(t("The indexing workflow was successfully edited. All content was scheduled for re-indexing so the new settings can take effect."));
    }
}
 /**
  * @return SearchApiIndex
  *   The index this search belongs to.
  */
 public function index()
 {
     if (!isset($this->index)) {
         $this->index = search_api_index_load($this->index_id);
         if (!$this->index) {
             $this->index = FALSE;
         }
     }
     return $this->index;
 }
Ejemplo n.º 3
0
 /**
  * Initializes context.
  *
  * Initializes all the search api indexes.
  */
 public function __construct($search_indexes = array(), $search_forms = array())
 {
     if (!empty($search_indexes)) {
         // If set, only use the specified indexes.
         foreach ($search_indexes as $index) {
             $this->search_indexes[$index] = search_api_index_load($index);
         }
     } else {
         // Load ALL the indexes.
         $this->search_indexes = search_api_index_load_multiple(false);
     }
     $this->search_forms = $search_forms;
 }
Ejemplo n.º 4
0
 /**
  * @Then the Dataset search updates behind the scenes
  */
 public function theDatasetSearchUpdatesBehindTheScenes()
 {
     $index = search_api_index_load('datasets');
     $items = search_api_get_items_to_index($index);
     search_api_index_specific_items($index, $items);
 }
Ejemplo n.º 5
0
 /**
  * @Then /^I index all units in search api$/
  */
 public function iIndexUnitsSearchApi()
 {
     $index = search_api_index_load('units');
     search_api_index_items($index, 100);
 }
Ejemplo n.º 6
0
 /**
  * @Then I should see all published datasets
  */
 public function iShouldSeeAllPublishedDatasets()
 {
     $session = $this->getSession();
     $page = $session->getPage();
     $search_region = $page->find('css', '.view-dkan-datasets');
     $search_results = $search_region->findAll('css', '.view-header');
     $index = search_api_index_load('datasets');
     $query = new SearchApiQuery($index);
     $results = $query->condition('type', 'dataset')->condition('status', '1')->execute();
     $total = count($results['results']);
     $text = $total . " results";
     foreach ($search_results as $search_result) {
         $found = $search_result->getText();
     }
     if ($found !== $text) {
         throw new \Exception("Found {$found} in the page but total is {$total}.");
     }
 }