Skip to content

Instantly share code, notes, and snippets.

@Anahkiasen
Created January 27, 2015 11:00
Show Gist options
  • Select an option

  • Save Anahkiasen/1113cc76569c6c82b025 to your computer and use it in GitHub Desktop.

Select an option

Save Anahkiasen/1113cc76569c6c82b025 to your computer and use it in GitHub Desktop.
<?php
use ElasticSearcher\ElasticSearcher;
class TagsTableSeeder extends Seeder
{
/**
* @type ElasticSearcher
*/
protected $search;
/**
* @param ElasticSearcher $search
*/
public function __construct(ElasticSearcher $search)
{
$this->search = $search;
}
/**
* Run the seeder
*/
public function run()
{
$tags = base_path('vendor/eneko/data-repository/data/words.txt');
$tags = file_get_contents($tags);
$tags = explode(PHP_EOL, $tags);
foreach ($tags as $key => $tag) {
$tags[$key] = array(
'tag' => $tag,
'source' => 'repository',
'num_used_in_groups' => 0,
'num_used_by_unique_users' => 0,
'used_in_groups' => [],
);
}
$this->search->documentsManager()->bulkIndex('tags', 'tags', $tags);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment