Newer
Older
<?php
namespace IQDEV\ElasticSearch\Document;
use IQDEV\ElasticSearch\Facet\FacetCategory;
use IQDEV\ElasticSearch\Facet\FacetCollection;
class ProductDocument implements Document
{
private FacetCollection $keywordFacets;
private FacetCollection $numberFacets;
private ?string $fullSearchContent = null;
private array $info;
public function __construct(FacetCategory $categoryFacet, array $info = [])
{
$this->keywordFacets = new FacetCollection();
$this->numberFacets = new FacetCollection();
$this->categoryFacet = $categoryFacet;
$this->info = $info;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
}
/**
* @return FacetCollection
*/
public function getKeywordFacets(): FacetCollection
{
return $this->keywordFacets;
}
/**
* @return FacetCategory
*/
public function getCategoryFacet(): FacetCategory
{
return $this->categoryFacet;
}
/**
* @return FacetCollection
*/
public function getNumberFacets(): FacetCollection
{
return $this->numberFacets;
}
/**
* @param string|null $fullSearchContent
*/
public function setFullSearchContent(?string $fullSearchContent): void
{
$this->fullSearchContent = $fullSearchContent;
}
public function es(): array
{
$document = [
'category_id' => $this->getCategoryFacet()->es()['category_id'],
'search_data' => [
'keyword_facet' => $this->getKeywordFacets()->es(),
'number_facet' => $this->getNumberFacets()->es()
],
'data' => $this->info