Elastica\Query\Match::setField PHP Method

setField() public method

Sets a param for the message array.
public setField ( string $field, mixed $values )
$field string
$values mixed
    public function setField($field, $values)
    {
        return $this->setParam($field, $values);
    }

Usage Example

Exemplo n.º 1
1
 public function publisherAction(Request $request, $page = 1)
 {
     $getTypes = $request->query->get('type_filters');
     $typeFilters = !empty($getTypes) ? explode(',', $getTypes) : [];
     $publisherSearcher = $this->get('fos_elastica.index.search.publisher');
     $boolQuery = new Query\Bool();
     if (!empty($typeFilters)) {
         foreach ($typeFilters as $type) {
             $match = new Query\Match();
             $match->setField('publisherType', $type);
             $boolQuery->addMust($match);
         }
     }
     $publisherQuery = new Query($boolQuery);
     $typeAgg = new Aggregation\Terms('types');
     $typeAgg->setField('publisherType');
     $typeAgg->setOrder('_term', 'asc');
     $typeAgg->setSize(0);
     $publisherQuery->addAggregation($typeAgg);
     $adapter = new ElasticaAdapter($publisherSearcher, $publisherQuery);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage(20);
     $pagerfanta->setCurrentPage($page);
     $publishers = $pagerfanta->getCurrentPageResults();
     $types = $adapter->getResultSet()->getAggregation('types')['buckets'];
     $data = ['types' => $types, 'page' => 'ojs_site_explore_publisher', 'publishers' => $publishers, 'pagerfanta' => $pagerfanta, 'type_filters' => $typeFilters];
     return $this->render('OjsSiteBundle:Explore:publisher.html.twig', $data);
 }
All Usage Examples Of Elastica\Query\Match::setField