You should instantiate a Client object with your ApplicationID, ApiKey and Hosts to start using Algolia Search API
 /**
  * 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")));
 }
Пример #2
0
 /**
  * Index all of the available documentation.
  *
  * @return void
  */
 public function indexAllDocuments()
 {
     foreach (Documentation::getDocVersions() as $key => $title) {
         $this->indexAllDocumentsForVersion($key);
     }
     $this->setSettings();
     $this->client->moveIndex($this->index->indexName, static::$index_name);
 }
Пример #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());
     }
 }
Пример #4
0
 /**
  * Index Exists.
  *
  * Does this index exist?
  *
  * @return bool
  */
 public function indexExists()
 {
     foreach (Arr::get($this->client->listIndexes(), 'items', []) as $index) {
         if ($index['name'] == $this->getConfigurator()->index()) {
             return true;
         }
     }
     return false;
 }
Пример #5
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]);
 }
Пример #6
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'));
 }
 /**
  * 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')));
         }
     }
 }
Пример #8
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;
 }
Пример #9
0
 public function moveIndex($index_name_tmp, $index_name)
 {
     $this->client->moveIndex($index_name_tmp, $index_name);
 }
Пример #10
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']);
 }
Пример #11
0
 /**
  * @inheritdoc
  */
 public function __construct($applicationID, $apiKey, $hostsArray = null, $options = array())
 {
     parent::__construct($applicationID, $apiKey, $hostsArray, $options);
 }
 public function generateSearchSecuredApiKey($key, $params = [])
 {
     return $this->client->generateSecuredApiKey($key, $params);
 }
Пример #13
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')));
 }
Пример #14
0
 /**
  * @inheritdoc
  */
 public function __construct($applicationID, $apiKey, $hostsArray = null, $options = array())
 {
     Version::$custom_value = ' Nette 1.0.1';
     parent::__construct($applicationID, $apiKey, $hostsArray, $options);
 }
 public function testHTTPSAccess()
 {
     $client = new Client(getenv('ALGOLIA_APPLICATION_ID'), getenv('ALGOLIA_API_KEY'), array("https://" . getenv('ALGOLIA_APPLICATION_ID') . "-1.algolia.io"));
     $client->isAlive();
 }