Stars: 312
Forks: 188
Pull Requests: 592
Issues: 391
Watchers: 31
Last Updated: 2023-03-20 13:34:43
Symfony bundle for Elasticsearch with steroids
License: MIT License
Languages: PHP, Twig
Elasticsearch Bundle was created in order to serve the need for professional Elasticsearch integration with enterprise level Symfony applications. This bundle is:
Technical goodies:
ongr:es:document:generate
)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
Elasticsearch version | ElasticsearchBundle version |
---|---|
>= 7.0 | ~7.x |
>= 6.0, < 7.0 | ~6.x |
>= 5.0, < 5.0 | ~5.x, ~6.x (indexes with 1 type) |
>= 2.0, < 5.0 | >=1.0, < 5.0 |
>= 1.0, < 2.0 | >= 0.10, < 1.0 |
<= 0.90.x | < 0.10 |
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.
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],
];
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.
Document
objectsThis 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.
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.
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
This bundle is licensed under the MIT license. Please, see the complete license
in the bundle LICENSE
file.