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
Copy file name to clipboardExpand all lines: doc/01_intro.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,27 @@ elasticSearch:
27
27
28
28
For more config options see default values in `\Spameri\Elastic\DI\ElasticSearchExtension::$defaults`. [Here](../src/DI/ElasticSearchExtension.php#L9).
29
29
30
+
#### Raw client usage
31
+
- After this configuration you are ready to use ElasticSearch in your Nette application.
32
+
- Where needed just inject `\Spameri\Elastic\ClientProvider` and then directly call what you need, like this:
-[Client](https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/Client.php) is provided from **elasticsearch/elasticsearch** and you can see their [documentation](https://github.com/elastic/elasticsearch-php#quickstart)
47
+
what methods and arrays are supported.
48
+
- When in doubt what how many arrays or how many arguments **match** supports use [Spameri/ElasticQuery](https://github.com/Spameri/ElasticQuery/blob/master/doc/02-query-objects.md)
49
+
- This is library used in later examples. But direct approach is also possible.
Copy file name to clipboardExpand all lines: doc/03_entity_class.md
+224-6Lines changed: 224 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,13 @@ class KeyWord implements \Spameri\Elastic\Entity\IValue
99
99
```
100
100
101
101
#### Value collection property - `Video.Story.KeyWordCollection`
102
-
TODO Description
102
+
- If you need array of scalar values lets create ValueCollection.
103
+
- For easy setup you can use `\Spameri\Elastic\Entity\AbstractValueCollection` just create your collection and extend this abstract as you need.
104
+
For more advanced and typed approach use interface, as described next.
105
+
- Interface `\Spameri\Elastic\Entity\IValueCollection` is when you want typed and validated scalar value collection.
106
+
- After implementing interface you need to implement **getIterator()** method.
107
+
- Next to be type save you want to add methods **add**, **remove**, **get**, **__construct**
108
+
- For **__construct** you best fill values to collection as here [\Spameri\Elastic\Entity\AbstractValueCollection#L20](../src/Entity/AbstractValueCollection.php#L20)
103
109
```php
104
110
namespace SpameriTests\Data\Entity\Video\Story;
105
111
@@ -125,13 +131,28 @@ class KeyWordCollection implements \Spameri\Elastic\Entity\IValueCollection
- ElasticSearch is powerful tool and it allows you to nest objects and collection as you need, so you can make collection of nested objects.
205
+
- This is simple you have Entity **Story** with implemented `IEntity` interface and all you need is create collection, extend `class FollowsCollection extends \Spameri\Elastic\Entity\Collection\EntityCollection`
-`\Spameri\Elastic\Entity\Collection\ElasticEntityCollection` provides basic relations for entities in ElasticSearch.
219
+
- It saves **_id** to current entity as reference in raw data but when loaded you have full entity with that id.
220
+
Any changes made to related entity/ies will be persisted when main entity is saved.
221
+
- Entity can be manually related 1:1 with manual lazy load in Factory (example in [factory](11_entity_factory.md) documentation)
222
+
- Or multiple entities can be in collection lazily loaded all at once, also in factory example.
223
+
- All you need is extend `\Spameri\Elastic\Entity\Collection\ElasticEntityCollection` and fill with your entities, library will do saving and resolving for you.
192
224
```php
193
225
namespace SpameriTests\Data\Entity\Video;
194
226
@@ -212,3 +244,189 @@ class People extends \Spameri\Elastic\Entity\Collection\ElasticEntityCollection
212
244
}
213
245
```
214
246
247
+
## Final product [Example](../tests/SpameriTests/Data/Entity/Video.php)
248
+
```php
249
+
namespace SpameriTests\Data\Entity;
250
+
251
+
252
+
class Video implements \Spameri\Elastic\Entity\IElasticEntity
0 commit comments