Smile\ElasticsuiteCore\Search\Request\Query\QueryFactory::create PHP Method

create() public method

Create a query from it's type and params.
public create ( string $queryType, array $queryParams ) : Smile\ElasticsuiteCore\Search\Request\QueryInterface
$queryType string Query type (must be a valid query type defined into the factories array).
$queryParams array Query constructor params.
return Smile\ElasticsuiteCore\Search\Request\QueryInterface
    public function create($queryType, $queryParams)
    {
        if (!isset($this->factories[$queryType])) {
            throw new \LogicException("No factory found for query of type {$queryType}");
        }
        return $this->factories[$queryType]->create($queryParams);
    }

Usage Example

Beispiel #1
0
 /**
  * Create a filtered query with an optional fulltext query part.
  *
  * @param ContainerConfigurationInterface $containerConfiguration Search request container configuration.
  * @param string|null                     $queryText              Fulltext query.
  * @param array                           $filters                Filter part of the query.
  * @param string                          $spellingType           For fulltext query : the type of spellchecked applied.
  *
  * @return QueryInterface
  */
 public function createQuery(ContainerConfigurationInterface $containerConfiguration, $queryText, array $filters, $spellingType)
 {
     $queryParams = [];
     if (!empty($filters)) {
         $queryParams = ['filter' => $this->filterQueryBuilder->create($containerConfiguration, $filters)];
     }
     if ($queryText) {
         $queryParams['query'] = $this->fulltextQueryBuilder->create($containerConfiguration, $queryText, $spellingType);
     }
     return $this->queryFactory->create(QueryInterface::TYPE_FILTER, $queryParams);
 }
All Usage Examples Of Smile\ElasticsuiteCore\Search\Request\Query\QueryFactory::create