Skip to content

Latest commit

 

History

History
26 lines (23 loc) · 707 Bytes

09_match_get.md

File metadata and controls

26 lines (23 loc) · 707 Bytes

Filter data

Description

You can specify complicated ElasticSearch Query and still get pretty entity. Service accepts \Spameri\ElasticQuery\ElasticQuery object and returns entity or collection depending if you want one or more results.

Example

In this example we are looking for video named 'Avengers' made in years from 2017 to 2018.

$elasticQuery = new \Spameri\ElasticQuery\ElasticQuery();
$elasticQuery->query()->must()->add(
	new \Spameri\ElasticQuery\Query\Range(
		'year',
		2017,
		2019
	)
);
$elasticQuery->query()->must()->add(
	new \Spameri\ElasticQuery\Query\ElasticMatch(
		'name',
		'Avengers'
	)
);

$video = $videoService->getBy($elasticQuery);