Documents
What are the available documents?
There are 2 documents available:
Aero\Search\Elastic\Documents\ListingsDocumentused to hold information about the listings that are shown on the storefront.Aero\Search\Elastic\Documents\ProductDocumentused to hold information about the products within the store’s catalog. It is generally used in the backend admin, to allow for quick access when managing products.
How can I extend the document structure?
To extend a document, use the add() method, to define a closure that will return an array of data to merge into the document structure:
\Aero\Search\Elastic\Documents\ListingDocument::add('search-result', function ($document) {
$colors = $document->getModel()
->visibleVariants()
->pluck('attributes')
->flatten()
->filter(function ($attribute) {
return strpos(strtolower($attribute->group->name), 'color') !== false;
})
->pluck('name')
->unique()
->values()
->all();
return [
'colors' => $colors,
];
});