You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -86,8 +83,10 @@ class SimpleProduct implements \Spameri\Elastic\Entity\IElasticEntity
86
83
}
87
84
```
88
85
86
+
And then implement two methods. Method id is quite clear :) and entityVariables method returns all the properties you want inserted to Elastic.
87
+
89
88
```php
90
-
public function id(): \Spameri\Elastic\Entity\Property\IElasticId
89
+
public function id(): \Spameri\Elastic\Entity\Property\ElasticIdInterface
91
90
{
92
91
return $this->id;
93
92
}
@@ -99,9 +98,11 @@ public function entityVariables(): array
99
98
}
100
99
```
101
100
101
+
To build entity from Elasticsearch and not use black magic🪄 you have to explicitly make factory class for that entity. And from hit object which represents result from Elasticsearch you have to extract all parameters. No magic, typed 🎖️
102
+
102
103
### Factory
103
104
````php
104
-
class SimpleProductFactory implements \Spameri\Elastic\Factory\IEntityFactory
105
+
class SimpleProductFactory implements \Spameri\Elastic\Factory\EntityFactoryInterface
105
106
{
106
107
107
108
public function create(\Spameri\ElasticQuery\Response\Result\Hit $hit) : \Generator
@@ -123,23 +124,27 @@ class SimpleProductFactory implements \Spameri\Elastic\Factory\IEntityFactory
123
124
}
124
125
````
125
126
127
+
In collection factory you need to specify our entity.
128
+
126
129
### CollectionFactory
127
130
````php
128
-
class SimpleProductCollectionFactory implements \Spameri\Elastic\Factory\ICollectionFactory
131
+
class SimpleProductCollectionFactory implements \Spameri\Elastic\Factory\CollectionFactoryInterface
0 commit comments