|
| 1 | +# ONGR FilterManagerBundle |
| 2 | + |
| 3 | +Filter manager is used for listing documents. It provides ties between commonly used filtering options and UI elements with Elasticsearch repositories. |
| 4 | +You can use it from a single controller. |
| 5 | +It is important to mention that filtering is everything what has impact on list, it can be: |
| 6 | +- Filtering on specific field value object have (color, country etc.) |
| 7 | +- Filtering range (price range, distance from point etc.) |
| 8 | +- Documents list pagination. Paging changes representation of list, so it is considered to be filter and is treated like one. |
| 9 | +- Documents list sorting. Same as paging - sorting is filter in this bundle. |
| 10 | +- Any custom factor which has influence (not always directly visible) on result list. It can exclude, boost, modify some results, collect some metrics or any other action you can imagine. |
| 11 | + |
| 12 | +[](https://travis-ci.org/ongr-io/FilterManagerBundle) |
| 13 | +[](https://scrutinizer-ci.com/g/ongr-io/FilterManagerBundle/?branch=master) |
| 14 | +[](https://scrutinizer-ci.com/g/ongr-io/FilterManagerBundle/?branch=master) |
| 15 | +[](https://insight.sensiolabs.com/projects/44c0f05e-a9a8-41ab-9acf-1225cef2887c) |
| 16 | +[](https://packagist.org/packages/ongr/filter-manager-bundle) |
| 17 | +[](https://packagist.org/packages/ongr/filter-manager-bundle) |
| 18 | +[](https://packagist.org/packages/ongr/filter-manager-bundle) |
| 19 | +[](https://packagist.org/packages/ongr/filter-manager-bundle) |
| 20 | + |
| 21 | +## Instalation |
| 22 | + |
| 23 | +### Step 1: Install FilterManager bundle |
| 24 | + |
| 25 | +FilterManager bundle is installed using [Composer](https://getcomposer.org). |
| 26 | + |
| 27 | +```bash |
| 28 | +$ composer require ongr/filter-manager-bundle "~1.0" |
| 29 | +``` |
| 30 | + |
| 31 | +> Please note that filter manager requires Elasticsearch bundle, guide on how to install and configure it can be found [here](https://github.com/ongr-io/ElasticsearchBundle). |
| 32 | +
|
| 33 | +### Step 2: Enable FilterManager bundle |
| 34 | + |
| 35 | +Enable Filter Manager bundle in your AppKernel: |
| 36 | + |
| 37 | +```php |
| 38 | +<?php |
| 39 | +// app/AppKernel.php |
| 40 | + |
| 41 | +public function registerBundles() |
| 42 | +{ |
| 43 | + $bundles = array( |
| 44 | + // ... |
| 45 | + new ONGR\ElasticsearchBundle\ONGRElasticsearchBundle(), |
| 46 | + new ONGR\FilterManagerBundle\ONGRFilterManagerBundle(), |
| 47 | + // ... |
| 48 | + ); |
| 49 | + |
| 50 | + // ... |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +### Step 3: Add configuration for manager |
| 55 | + |
| 56 | +Add minimal configuration for Elasticsearch and FilterManager bundles. |
| 57 | + |
| 58 | +```yaml |
| 59 | +# app/config/config.yml |
| 60 | + |
| 61 | +ongr_elasticsearch: |
| 62 | + connections: |
| 63 | + default: |
| 64 | + hosts: |
| 65 | + - 127.0.0.1:9200 |
| 66 | + index_name: items |
| 67 | + managers: |
| 68 | + default: |
| 69 | + connection: default |
| 70 | + |
| 71 | +ongr_filter_manager: |
| 72 | + managers: |
| 73 | + item_list: # <- Filter manager name |
| 74 | + filters: |
| 75 | + - country |
| 76 | + repository: 'es.manager.default.item' |
| 77 | + filters: |
| 78 | + choice: |
| 79 | + country: # <- Filter name |
| 80 | + request_field: 'country' |
| 81 | + field: country |
| 82 | +``` |
| 83 | +> Note that `Item` document has to be defined. More about that in ElasticsearchBundle [documentation](https://github.com/ongr-io/ElasticsearchBundle/blob/master/Resources/doc/mapping.md). |
| 84 | + |
| 85 | +In this particular example, we defined a single filter manager named `item_list` to filter documents from item repository, and we will be using the filter named `country` to filter on countries defined in document. |
| 86 | + |
| 87 | +### Step 4: Use your new bundle |
| 88 | + |
| 89 | +FilterManagerBundle is ready to use. You can take a look at our [search page example](Resources/doc/examples/search_example.md). |
| 90 | + |
| 91 | + |
| 92 | +## Documentation |
| 93 | + |
| 94 | +The online documentation of the bundle is in [Github](Resources/doc/index.md). |
| 95 | + |
| 96 | +## License |
| 97 | + |
| 98 | +This bundle is covered by the MIT license. Please see the complete license in the bundle [LICENSE](LICENSE) file. |
0 commit comments