Skip to content

Latest commit

 

History

History
103 lines (66 loc) · 2.41 KB

01_intro.md

File metadata and controls

103 lines (66 loc) · 2.41 KB

Intro

Install

Use composer composer require spameri/elastic

Usage

1. Config ElasticSearch

In your config neon, enable extensions. Kdyby/Console is there because we need it to do some command line commands.

extensions:
	spameriElasticSearch: \Spameri\Elastic\DI\SpameriElasticSearchExtension

Optionaly you need some Symfony Console implementation ie:

extensions:
	console: Kdyby\Console\DI\ConsoleExtension

Then configure where is your ElasticSearch.

spameriElasticSearch:
	host: 127.0.0.1
	port: 9200

For more config options see default values in \Spameri\Elastic\DI\SpameriElasticSearchExtension::$defaults. Here.

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:
$result = $this->clientProvider->client()->search(
	(
		new \Spameri\ElasticQuery\Document(
			$index,
			new \Spameri\ElasticQuery\Document\Body\Plain(
				$elasticQuery->toArray()
			)
		)
	)->toArray()
);
  • Client is provided from elasticsearch/elasticsearch and you can see their documentation what methods and arrays are supported.
  • When in doubt what how many arrays or how many arguments match supports use Spameri/ElasticQuery
  • This is library used in later examples. But direct approach is also possible.

2. First entity


3. Mapping


4. Fill with data


5. Get data from ElasticSearch


6. Filter data from ElasticSearch


7. Aggregate data from ElasticSearch


x. Other