Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Adapter Class Reference
Inheritance diagram for Adapter:
AdapterInterface

Public Member Functions

 __construct (ConnectionManager $connectionManager, Mapper $mapper, ResponseFactory $responseFactory, AggregationBuilder $aggregationBuilder, QueryContainerFactory $queryContainerFactory=null)
 
 query (RequestInterface $request)
 

Protected Attributes

 $mapper
 
 $responseFactory
 
 $connectionManager
 
 $aggregationBuilder
 

Detailed Description

Elasticsearch Search Adapter

Definition at line 17 of file Adapter.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ConnectionManager  $connectionManager,
Mapper  $mapper,
ResponseFactory  $responseFactory,
AggregationBuilder  $aggregationBuilder,
QueryContainerFactory  $queryContainerFactory = null 
)
Parameters
ConnectionManager$connectionManager
Mapper$mapper
ResponseFactory$responseFactory
AggregationBuilder$aggregationBuilder
QueryContainerFactory$queryContainerFactory

Definition at line 55 of file Adapter.php.

61  {
62  $this->connectionManager = $connectionManager;
63  $this->mapper = $mapper;
64  $this->responseFactory = $responseFactory;
65  $this->aggregationBuilder = $aggregationBuilder;
66  $this->queryContainerFactory = $queryContainerFactory
67  ?: ObjectManager::getInstance()->get(QueryContainerFactory::class);
68  }

Member Function Documentation

◆ query()

query ( RequestInterface  $request)
Parameters
RequestInterface$request
Returns
QueryResponse

Implements AdapterInterface.

Definition at line 74 of file Adapter.php.

75  {
76  $client = $this->connectionManager->getConnection();
78 
79  $query = $this->mapper->buildQuery($request);
80  $aggregationBuilder->setQuery($this->queryContainerFactory->create(['query' => $query]));
81  $rawResponse = $client->query($query);
82 
83  $rawDocuments = isset($rawResponse['hits']['hits']) ? $rawResponse['hits']['hits'] : [];
84 
85  $queryResponse = $this->responseFactory->create(
86  [
87  'documents' => $rawDocuments,
88  'aggregations' => $aggregationBuilder->build($request, $rawResponse),
89  ]
90  );
91  return $queryResponse;
92  }

Field Documentation

◆ $aggregationBuilder

$aggregationBuilder
protected

Definition at line 41 of file Adapter.php.

◆ $connectionManager

$connectionManager
protected

Definition at line 36 of file Adapter.php.

◆ $mapper

$mapper
protected

Definition at line 24 of file Adapter.php.

◆ $responseFactory

$responseFactory
protected

Definition at line 31 of file Adapter.php.


The documentation for this class was generated from the following file: