Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
65
66
67
68
69
70
71
<?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 FacetCategory $categoryFacet;
public function __construct(FacetCategory $categoryFacet)
{
$this->keywordFacets = new FacetCollection();
$this->numberFacets = new FacetCollection();
$this->categoryFacet = $categoryFacet;
}
/**
* @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()
],
];
if ($this->fullSearchContent) {
$document['full_search_content'] = $this->fullSearchContent;
}
return $document;
}
}