initIndex() public method

Get the index object initialized (no server call needed for initialization).
public initIndex ( string $indexName ) : Index
$indexName string the name of index
return Index
 /**
  * AlgoliaSearchEngine constructor.
  * @param \AlgoliaSearch\Client $client
  * @param $index
  */
 public function __construct(\AlgoliaSearch\Client $client, $index, $clearOnSync)
 {
     $this->client = $client;
     $this->index = $client->initIndex($index);
     $this->clearOnSync = $clearOnSync;
     $this->index->setSettings(array("attributesToIndex" => array("content", "title", "categories", "tags"), "attributesForFaceting" => array("categories", "tags")));
 }
 /**
  * Creates a connection to the Algolia Search server as configured in $this->configuration.
  */
 protected function connect($index = NULL)
 {
     if (!$this->getAlgolia()) {
         $this->algoliaClient = new \AlgoliaSearch\Client($this->getApplicationId(), $this->getApiKey());
         if ($index && $index instanceof IndexInterface) {
             $this->setAlgoliaIndex($this->algoliaClient->initIndex($index->get('name')));
         }
     }
 }
Example #3
0
 public function deletePost($post_id)
 {
     $post = get_post($post_id);
     if ($post->post_type != 'nav_menu_item') {
         $client = new Client('NROWAPEEW3', '6e4bffbe64f9f15550f1aa0f73aea3c0');
         $index = $client->initIndex('VisionDevIndex');
         $index->deleteObject($post->ID . get_current_blog_id());
     }
 }
Example #4
0
 public function handle()
 {
     //Artisan::call('scout:flush', ['model' => Product::class]);
     // scout's own clear command only clears the currently existing products
     $algolia = new Algolia(config('scout.algolia.id'), config('scout.algolia.secret'));
     $product = new Product();
     $index = $algolia->initIndex($product->searchableAs());
     $index->clearIndex();
     Artisan::call('scout:import', ['model' => Product::class]);
 }
Example #5
0
 public function search(Repository $cache, $search = 'enchantment')
 {
     $client = new Client(config('algolia.connections.main.id'), config('algolia.connections.main.key'));
     //if ($cache->has('origins.'. $search)) {
     //    $cards = $cache->get($search);
     //} else {
     $index = $client->initIndex(config('algolia.index'));
     $index->setSettings(['attributesForFaceting' => ['colors', 'multiverseid']]);
     $cards = $index->search($search, ['facets' => '*', 'facetFilters' => 'colors:Green'])['hits'];
     foreach ($cards as $index => $card) {
         if (isset($card['manaCost'])) {
             $cards[$index]['manaCost'] = preg_replace('/{(.)}/', '<img src="/images/blank.png" id="$1" />', $card['manaCost']);
         }
     }
     $cache->forever($search, $cards);
     //}
     $this->setJavascriptData(compact('cards'));
 }
Example #6
0
 /**
  * Set the name of the index that should be used by default.
  *
  * @param $indexName
  *
  * @return $this
  */
 public function setIndexName($indexName)
 {
     $this->index = $this->algolia->initIndex($indexName);
     return $this;
 }
 public function query($index_name, $q, $params)
 {
     return $this->client->initIndex($index_name)->search($q, $params);
 }
Example #8
0
 public function __construct($configuration)
 {
     $configuration = array_replace(array('index' => 'saku'), $configuration);
     $this->client = new \AlgoliaSearch\Client($configuration['applicationId'], $configuration['apiKey']);
     $this->index = $this->client->initIndex($configuration['index']);
 }
 public function query($index_name, $q, $params)
 {
     $this->checkClient(__FUNCTION__);
     return $this->client->initIndex($index_name)->search($q, $params);
 }
Example #10
0
 /**
  * @param Client $client
  * @param string $indexName
  */
 public function __construct(Client $client, $indexName)
 {
     $this->index = $client->initIndex($indexName);
     $this->index->setSettings(array("attributesToIndex" => array("title", "tags", "unordered(body)"), 'attributesForFaceting' => array('tags')));
 }
Example #11
0
 /**
  * Create Index.
  *
  * @return Index
  */
 public function createIndex()
 {
     return $this->client->initIndex($this->getConfigurator()->index());
 }