/**
  * @Route("/autocomplete/{type}")
  */
 public function locationAction($type)
 {
     $term = trim($this->getRequest()->get('term', null));
     if ($term === null || strlen($term) === 0) {
         throw new \InvalidArgumentException('No search term specified');
     }
     $q = new Query(Query::escape($term) . '*', 'name_t');
     $q->andTerm($type, 'type_s');
     $result = $this->solr->search($q);
     $data = array();
     foreach ($result as $item) {
         $data[] = array('id' => $item->meta_id, 'label' => $item->meta_name);
     }
     $res = new Response(json_encode($data));
     $res->headers->set('Content-Type', 'application/json');
     return $res;
 }
 public function search(Query $query, $offset = 0, $limit = 10)
 {
     $queryString = $query->toString();
     $response = $this->service->search($queryString, $offset, $limit);
     return new ResultSet($response, $queryString, $offset, $limit);
 }