Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dpb587/elasticsearch-in-memory-filter.php
Reuse elasticsearch filters for matching in-memory arrays.
https://github.com/dpb587/elasticsearch-in-memory-filter.php
Last synced: 24 days ago
JSON representation
Reuse elasticsearch filters for matching in-memory arrays.
- Host: GitHub
- URL: https://github.com/dpb587/elasticsearch-in-memory-filter.php
- Owner: dpb587
- License: mit
- Created: 2016-12-28T19:28:06.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-21T15:11:27.000Z (about 7 years ago)
- Last Synced: 2024-10-30T18:13:34.351Z (2 months ago)
- Language: PHP
- Size: 9.77 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elasticsearch-in-memory-filter.php
Reuse elasticsearch filters for matching in-memory arrays.
## Example
```php
use DPB\ElasticsearchInMemoryFilter as _;$doc = [
'name' => 'Dublin Pizza Company',
'type' => 'restaurant',
'categories' => [
[ 'id' => 12345,
'name' => 'pizza' ] ] ];$esFilter = [
'and' => [
[ 'term' => [
'type' => 'restaurant' ] ],
[ 'nested' => [
'path' => 'categories',
'filter' => [
'term' => [
'categories.name' => 'pizza' ] ] ] ] ] ];$filter = _\Transformer::transform($esFilter);
var_export($filter->match($doc));
// true$filter = new _\Filter\TermFilter([ 'type' => 'restaurant' ]);
var_export($filter->match($doc));
// truevar_export($filter->match([ 'type' => 'cafe' ]));
// false
```## License
[MIT License](./LICENSE)