Esempio n. 1
0
 public function autosuggest($text)
 {
     $queryString = new QueryString($text);
     $elasticaQuery = new ElasticaQuery($queryString);
     $elasticaQuery->setSize(10);
     $result = $this->elastica->search($elasticaQuery, 'locations');
     return $this->prepareSuggestResult($result);
 }
Esempio n. 2
0
 private function indexLocations()
 {
     $this->total = DB::table('phpjob_zipcodes')->count();
     $this->processed = 0;
     $this->write('info', '=== [LOCATIONS] ===');
     Location::chunk($this->batch, function ($locations) {
         $offset = $this->processed;
         $this->processed += count($locations);
         $documents = [];
         foreach ($locations as $location) {
             $document = $this->elastica->createDocument([], 'locations', 'activehire', $location->id);
             $document = $this->locationTransformer->toDocument($location, $document);
             $documents[] = $document;
         }
         $this->elastica->addDocuments($documents);
         $this->write('info', 'Indexed locations from ' . $offset . ' to ' . $this->processed . ' (' . floor($this->processed / $this->total * 100) . '%).');
     });
     $this->write('info', '=== [/LOCATIONS] ===');
 }