ongr / elasticsearch-bundle
Elasticsearch bundle for Symfony.
Installs: 1 094 598
Dependents: 22
Suggesters: 1
Security: 0
Stars: 312
Watchers: 31
Forks: 189
Open Issues: 59
Type:symfony-bundle
Requires
- php: ^7.1 || ^8.0
- doctrine/annotations: ^1.6
- doctrine/cache: ^1.7
- doctrine/collections: ^1.5
- doctrine/inflector: ^1.3
- elasticsearch/elasticsearch: ^7.0|^8.0
- monolog/monolog: ^1.24
- ongr/elasticsearch-dsl: ^7.0
- symfony/cache: ^4.4|^5.0
- symfony/console: ^4.4|^5.0
- symfony/dependency-injection: ^4.4|^5.0
- symfony/finder: ^4.4|^5.0
- symfony/framework-bundle: ^4.4|^5.0
- symfony/property-access: ^4.4|^5.0
- symfony/serializer: ^4.4|^5.0|^6.0
- symfony/stopwatch: ^4.4|^5.0
Requires (Dev)
- mikey179/vfsstream: ~1.6
- phpunit/phpunit: ^7.0
- squizlabs/php_codesniffer: ^3.0
- symfony/browser-kit: ^4.4|^5.0
- symfony/expression-language: ^4.4|^5.0
- symfony/options-resolver: ^4.4|^5.0
- symfony/twig-bundle: ^4.4|^5.0
- symfony/validator: ^4.4|^5.0
- symfony/yaml: ^4.4|^5.0
- v7.1.0
- 7.0.x-dev
- dev-master / 7.0.x-dev
- v7.0.6
- v7.0.5
- v7.0.4
- v7.0.3
- v7.0.2
- v7.0.1
- v7.0.0
- 6.3.x-dev
- v6.3.0
- 6.2.x-dev
- v6.2.3
- v6.2.2
- v6.2.1
- v6.2.0
- 6.1.x-dev
- v6.1.0
- v6.1.0-beta
- 6.0.x-dev
- v6.0.1
- v6.0.0
- v6.0.0-beta2
- v6.0.0-beta
- 5.2.x-dev
- v5.2.6
- v5.2.5
- v5.2.4
- v5.2.3
- v5.2.2
- v5.2.1
- v5.2.0
- 5.1.x-dev
- 5.0.x-dev
- v5.0.7
- v5.0.6
- v5.0.5
- v5.0.4
- v5.0.3
- v5.0.2
- v5.0.1
- v5.0.0
- v5.0.0-rc3
- v5.0.0-rc2
- v5.0.0-rc1
- 1.2.x-dev
- v1.2.10
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- 1.1.x-dev
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- 1.0.x-dev
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-alpha.7
- v1.0.0-alpha.6
- v1.0.0-alpha.5
- v1.0.0-alpha.4
- v1.0.0-alpha.3
- v1.0.0-alpha.2
- v1.0.0-alpha.1
- v0.10.8
- v0.10.7
- v0.10.6
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.4
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9.0
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.0
- v0.6.0
- v0.5.1
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.0
- dev-legacy
This package is auto-updated.
Last update: 2024-12-16 10:08:06 UTC
README
Elasticsearch Bundle was created in order to serve the need for professional Elasticsearch integration with enterprise level Symfony applications. This bundle is:
- Uses the official elasticsearch-php client.
- Ensures full integration with Symfony framework and Symfony Flex.
Technical goodies:
- Provides a DSL query builder which represent all ElasticSearch endpoints in the objective way.
- Provides interactive Document object generator via CLI command (
ongr:es:document:generate
) - Creates a familiar Doctrine-like way to work with documents(entities) document-object mapping using annotations.
- Several query results iterators are provided for your convenience to work with results.
- Console CLI commands for the index management and data import/export/reindex.
- Profiler that integrates in the Symfony debug bar and shows all executed queries.
- Designed in an extensible way for all your custom needs.
- Supports Symfony FLEX.
If you need any help, stack overflow is the preferred way to get answers. is the preferred and recommended way to ask questions about ONGR bundles and libraries.
If you like this library, help me to develop it by buying a cup of coffee
Version matrix
Documentation
The online documentation of the bundle can be found in http://docs.ongr.io.
Docs source is stored within the repo under Resources/doc/
, so if you see a typo or some inaccuracy, please submit a PR or at least an issue to fix it!
For contribution to the documentation you can find it in the contribute topic.
FAQ
- Index mapping
- Configuration
- Console commands
- How to do simple CRUD actions
- Quick find functions
- How to execute search in the index
- Parsing the results
Setup the bundle
Step 1: Install Elasticsearch bundle
Elasticsearch bundle is installed using Composer.
php composer.phar require ongr/elasticsearch-bundle "~6.0"
Instructions for installing and deploying Elasticsearch can be found in Elasticsearch installation page.
Enable ElasticSearch bundle in your AppKernel:
<?php // config/bundles.php return [ // ... ONGR\ElasticsearchBundle\ONGRElasticsearchBundle::class => ['all' => true], ];
(OPTIONAL) Step 2: Add configuration
Add minimal configuration for Elasticsearch bundle.
# config/packages/ongr_elasticsearch.yaml ongr_elasticsearch: analysis: filter: edge_ngram_filter: #-> your custom filter name to use in the analyzer below type: edge_ngram min_gram: 1 max_gram: 20 analyzer: eNgramAnalyzer: #-> analyzer name to use in the document field type: custom tokenizer: standard filter: - lowercase - edge_ngram_filter #that's the filter defined earlier indexes: App\Document\Product: hosts: [elasticsearch:9200] # optional, the default is 127.0.0.1:9200
This is the very basic example only, for more information, please take a look at the configuration chapter.
Step 3: Define your Elasticsearch types as Document
objects
This bundle uses objects to represent Elasticsearch documents. Lets create the Product
class for the products
index.
// src/Document/Product.php namespace App\Document; use ONGR\ElasticsearchBundle\Annotation as ES; /** * //alias and default parameters in the annotation are optional. * @ES\Index(alias="products", default=true) */ class Product { /** * @ES\Id() */ public $id; /** * @ES\Property(type="text", analyzer="eNgramAnalyzer") */ public $title; /** * @ES\Property(type="float") */ public $price; }
This is the basic example only, for more information about a mapping, please take a look at the the mapping chapter.
Step 4: Create index and mappings
Elasticsearch bundle provides several CLI
commands. One of them is for creating an index, run the command in your terminal:
bin/console ongr:es:index:create
Now the products
index should be created with fields from your document.
More info about the rest of the commands can be found in the commands chapter.
Step 5: Enjoy with the Elasticsearch
Full documentation for the Elasticsearch bundle is available here. I hope you will create amazing things with it 😎 .
Please note that the updating process of the documentation of the bundle to 6.0 is still under way. Read the configuration and crud sections that are already updated and will allow you to have the basic functions of the bundle. We will update the rest of the documentation as soon as possible
Troubleshooting
License
This bundle is licensed under the MIT license. Please, see the complete license
in the bundle LICENSE
file.