コード例 #1
0
ファイル: SearchSpeed.php プロジェクト: jaffle-be/framework
 public function handle()
 {
     $client = $this->search->getClient();
     $speed = $this->argument('speed') ? $this->argument('speed') : $this->config->getSpeed();
     $settings = ['index' => $this->config->getIndex(), 'body' => ['index' => ['refresh_interval' => $speed]]];
     $client->indices()->putSettings($settings);
 }
コード例 #2
0
 /**
  * @param Request $request
  * @param Product $products
  * @param SearchServiceInterface $search
  * @param GammaSubscriptionManager $subscriptions
  * @return mixed
  */
 public function index(Request $request, Product $products, SearchServiceInterface $search, GammaSubscriptionManager $subscriptions)
 {
     $thumbnailRequirements = function ($query) {
         $query->dimension(150);
     };
     //only products from the subscription accounts
     $indexes = $this->indexesToUse($subscriptions);
     $query = ['index' => $indexes, 'type' => $products->getSearchableType(), 'body' => ['query' => ['filtered' => ['query' => ['match_all' => new \StdClass()]]]]];
     return $search->search('products', $query, ['brand', 'brand.translations', 'images', 'images.sizes' => $thumbnailRequirements, 'images.translations']);
 }
コード例 #3
0
 /**
  * @param Request $request
  * @param Post $post
  * @param SearchServiceInterface $search
  * @param AccountManager $account
  * @return \Illuminate\Contracts\View\View
  */
 public function index(Request $request, Post $post, SearchServiceInterface $search, AccountManager $account)
 {
     $locale = app()->getLocale();
     if ($request->get('query')) {
         $posts = $search->search('posts', $this->postsQuery($request, $account, $locale), ['images'], false);
         $projects = $search->search('projects', $this->projectsQuery($request, $account, $locale), ['images'], false);
     } else {
         $posts = new Collection();
         $projects = new Collection();
     }
     return $this->theme->render('search.index', ['posts' => $posts, 'projects' => $projects]);
 }
コード例 #4
0
 /**
  * @param Request $request
  * @param ProductSelection $selections
  * @param SearchServiceInterface $search
  * @param Product $products
  * @param AccountManager $account
  * @return mixed
  */
 public function index(Request $request, ProductSelection $selections, SearchServiceInterface $search, Product $products, AccountManager $account, IndexManager $indexer)
 {
     $account = $account->account();
     //bazinga, we can now fully search using elasticsearch.
     //we don't care about the nearly realtime
     //even a minute would be acceptable, for blazing fast sites.
     //allright
     $indexes = $account->alias;
     $query = ['index' => $indexes, 'type' => $selections->getSearchableType(), 'body' => ['query' => ['filtered' => ['query' => ['match_all' => new \StdClass()]]]]];
     $relations = ['product', 'product.translations', 'product.images', 'product.images.sizes' => function ($query) {
         $query->dimension(150);
     }, 'product.brand', 'product.brand.translations'];
     $result = $search->search($selections->getSearchableType(), $query, $relations);
     return $result;
 }
コード例 #5
0
ファイル: SearchBuild.php プロジェクト: jaffle-be/framework
 /**
  * Execute the console command.
  *
  *
  */
 public function fire()
 {
     $this->call('search:speed', ['speed' => '5m']);
     $this->indexManager->allAliases();
     $types = $this->argument('types');
     if (empty($types)) {
         $types = config('search.types');
         $types = array_keys($types);
     }
     foreach ($types as $type) {
         $started = microtime(true);
         $this->line(ucfirst($type));
         $this->service->build($type);
         $seconds = microtime(true) - $started;
         $this->info(sprintf('%s seconds', $seconds));
     }
     $this->call('search:speed');
 }
コード例 #6
0
ファイル: SearchFlush.php プロジェクト: jaffle-be/framework
 /**
  * Execute the console command.
  *
  *
  */
 public function fire()
 {
     $this->service->flush();
 }
コード例 #7
0
 /**
  * Execute the console command.
  *
  *
  */
 public function fire()
 {
     $settings = config('search.settings');
     $this->service->updateSettings($settings);
 }
コード例 #8
0
 /**
  * @param Request $request
  * @param AccountManager $manager
  * @param SearchServiceInterface $search
  * @return Collection
  */
 public function search(Request $request, AccountManager $manager, SearchServiceInterface $search)
 {
     $this->validate($request, ['query' => 'required', 'locale' => 'required']);
     //we want to be able to select any of the following:
     // - product
     // - post
     // - project
     // - maybe even a page?
     $query = $this->postsQuery($request, $manager, $request->get('locale'));
     $posts = $search->search('posts', $query, [], false);
     $query = $this->projectsQuery($request, $manager, $request->get('locale'));
     $projects = $search->search('projects', $query, [], false);
     $result = new Collection();
     foreach ($posts as $post) {
         $result->push(['label' => 'post: ' . $post->translate($request->get('locale'))->title, 'type' => Post::class, 'value' => $post->id]);
     }
     foreach ($projects as $project) {
         $result->push(['label' => 'project: ' . $project->translate($request->get('locale'))->title, 'type' => Project::class, 'value' => $project->id]);
     }
     return $result;
 }