Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
454 changes: 454 additions & 0 deletions doc/00_quick_start.md

Large diffs are not rendered by default.

77 changes: 60 additions & 17 deletions doc/01_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,92 @@ Use composer `composer require spameri/elastic`
In your config neon, enable extensions. Kdyby/Console is there because we need it to do some command line commands.
Monolog is required by elasticsearch/elasticsearch and we can use existing extension in Kdyby/Monolog.

```
```neon
extensions:
elasticSearch: \Spameri\Elastic\DI\ElasticSearchExtension
spameriElasticSearch: \Spameri\Elastic\DI\SpameriElasticSearchExtension
console: Kdyby\Console\DI\ConsoleExtension
monolog: Kdyby\Monolog\DI\MonologExtension
```

Then configure where is your ElasticSearch.
```
elasticSearch:
```neon
spameriElasticSearch:
host: 127.0.0.1
port: 9200
```

For more config options see default values in `\Spameri\Elastic\DI\ElasticSearchExtension::$defaults`.
For more config options see default values in `\Spameri\Elastic\DI\SpameriElasticSearchExtension::$defaults`. [Here](../src/DI/ElasticSearchExtension.php#L9).

#### Raw client usage
- After this configuration you are ready to use ElasticSearch in your Nette application.
- Where needed just inject `\Spameri\Elastic\ClientProvider` and then directly call what you need, like this:
```php
$result = $this->clientProvider->client()->search(
(
new \Spameri\ElasticQuery\Document(
$index,
new \Spameri\ElasticQuery\Document\Body\Plain(
$elasticQuery->toArray()
),
$index
)
)->toArray()
);
```
- [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)
what methods and arrays are supported.
- 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)
- This is library used in later examples. But direct approach is also possible.

---

### 2. First entity

#### [Neon file configuration](../blob/master/doc/02_neon_configuration.md)
#### [Neon file configuration](02_neon_configuration.md)

#### [Create entity class](03_entity_class.md)

#### [Create Entity class](../blob/master/doc/03_entity_class.md)
#### [Create entity service](12_entity_service.md)

#### [Create entity factory](11_entity_factory.md)

---

### 3. Mapping

#### [Create new index with mapping]((../blob/master/doc/05_new_index_with_mapping.md))
#### [Create new index with mapping](05_new_index_with_mapping.md)

---

### 4. Fill with data
TODO

#### [Create and save entity](06_fill_data.md)

#### [Saving process explained](07_save_explained.md)

---

### 5. Get data from ElasticSearch
TODO Tady factories
TODO
TODO
TODO
TODO

#### [Get data by ID](08_basic_get.md)

#### [Get data by tag](13_advanced_get.md)

---

### 6. Filter data from ElasticSearch
TODO

#### [Match data](09_match_get.md)

---

### 7. Aggregate data from ElasticSearch
TODO

#### [Aggregate data](10_aggregate.md)

---

### x. Other

#### [Data interfaces]((../blob/master/doc/04_data_interfaces.md))
#### [Data interfaces](04_data_interfaces.md)

9 changes: 5 additions & 4 deletions doc/02_neon_configuration.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Define structure in neon file
TODO convert to video example

- Create neon file for example in `app/ProductModule/Config/Product.neon`
- Import created file to your application config neon. Usually located in`app/config/config.neon`.
Expand All @@ -12,7 +13,7 @@ have to worry about it because of type deprecation. More details here https://ww
- Entity definition is in neon under namespace `elasticSearch.entities.EntityName`
continuing our example in file `app/ProductModule/Config/Product.neon`:
```neon
elasticSearch:
spameriElasticSearch:
entities:
Product:
index: shop_product
Expand All @@ -24,15 +25,15 @@ This means newly introduced fields not specified in mapping will throw error whe
all fields introduced and specify their type. But if your application can add fields as needed you need to remember this
strict limitation or just do not enable it.
```neon
elasticSearch:
spameriElasticSearch:
entities:
Product:
dynamic: strict
```
- Now to specify entity mapping. Each object or encapsulation of sub fields stars with `properties:` then property name
and under it you can specify type and analyzer.
```neon
elasticSearch:
spameriElasticSearch:
entities:
Product:
properties:
Expand All @@ -45,7 +46,7 @@ elasticSearch:
- ElasticSearch default analyzers: https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-analyzers.html
- Subfields example:
```neon
elasticSearch:
spameriElasticSearch:
entities:
Product:
properties:
Expand Down
Loading