DoctrineSolrBundle
DoctrineSolrBundle is a Symfony bundle designed to mitigate Solr usage in symfony projects
Features
- Auto-indexing doctrine entities in Solr
- Supports wildcard, fuzzy & negative searches by specific entity fields
- Supports Range searches by specific entity fields
- Supports Boosting a Term by specific entity fields
- Supports Solr SuggestComponent
- Supports filters by entity fields or custom symfony service before indexing
- Auto-resolving search results in Doctrine entities
- Supports implementation of separate finder class for particular entity class
- Flexible query building interface
- Cross-search over different entity classes
Installation
Step 1 Download DoctrineSolrBundle using composer
$ composer require mdiyakov/doctrine-solr-bundle
Composer will install the bundle to your project's vendor/mdiyakov/doctrine-solr-bundle directory.
Step 2
Enable the bundle in the kernel :
```
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Nelmio\SolariumBundle\NelmioSolariumBundle(),
new Mdiyakov\DoctrineSolrBundle\MdiyakovDoctrineSolrBundle(),
// ...
);
}
```
You have to install "NelmioSolariumBundle" also because it's used by MdiyakovDoctrineSolrBundle
Step 3 : Quick start with DoctrineSolrBundle
Prerequisites
- Solr schema.yml created and solr core is initialized
- Solr schema.yml unique field is "uid"
- Solr schema.yml consists "document_id", "document_title" and "discriminator" fields
- AppBundle\Entity\MyEntity is created and has "id" and "title" fields
DoctrineSolrBundle is using "NelmioSolariumBundle" for solarium integration. So you need to set a configuration to use it. Here is minimum config:
yml
nelmio_solarium: ~
The default solr endpoint will be used in this case (http://localhost:8983/solr)
Init bundle configuration in config.yml. Quick example:
mdiyakov_doctrine_solr:
indexed_entities:
my_entity:
class: AppBundle\Entity\MyEntity
schema: my_schema
config:
- { name: config_field_name, value: config_field_value }
schemes:
my_schema:
document_unique_field: { name: 'uid' }
config_entity_fields:
- { config_field_name: 'config_field_name', document_field_name: 'discriminator', discriminator: true }
fields:
- { entity_field_name: 'id', document_field_name: 'document_id', field_type: int, entity_primary_key: true }
- { entity_field_name: 'title', document_field_name: 'document_title', suggester: 'title' }
As a result "id" and "title" fields of "AppBundle\Entity\MyEntity" will be synced with Solr
each time "AppBundle\Entity\MyEntity" is created, updated or removed.
If you use doctrine/orm < 2.5 then you have to add an annotation to "AppBundle\Entity\MyEntity" class:
@ORM\EntityListeners({"Mdiyakov\DoctrineSolrBundle\EventListener\DoctrineEntityListener"})
To search "AppBundle\Entity\MyEntity" use the following code:
// MyController
//...
// @var \Mdiyakov\DoctrineSolrBundle\Finder\ClassFinder $finder
$finder = $this->get('ds.finder')->getClassFinder(MyEntity::class);
/** @var MyEntity[] $searchResults */
$searchResults = $finder->findSearchTermByFields($searchTerm, ['title']);
//...
Next steps
mdiyakov_doctrine_solr:
indexed_entities:
# Prototype
name:
class: ~
schema: ~
filters: []
finder_class: ~
config:
name: ~
value: ~
schemes:
# Prototype
name:
client: ~
document_unique_field:
name: ~
config_entity_fields:
config_field_name: ~
document_field_name: ~
priority: 0
discriminator: false
fields:
entity_field_name: ~
document_field_name: ~
field_type: string
entity_primary_key: false
priority: 0
suggester: ~
filters:
fields:
# Prototype
name:
entity_field_name: ~
entity_field_value: ~
operator: ~
services:
# Prototype
name:
service: ~
solarium_clients:
# Prototype
name: []
-
Update README.md
By web-flow, 1 year ago
-
php5.4 compatibility
By mdiyakov, 1 year ago
-
unit tests for hydrator, ClassSelectQuery, MultiClassSelectQuery
By mdiyakov, 1 year ago
-
fixed unit test fixtures; composer.json for "symfony/property-access
By mdiyakov, 1 year ago
-
abstract select query test and fixes
By mdiyakov, 1 year ago
-
date field type
By mdiyakov, 1 year ago
-
Merge branch 'master' of github.com:mdiyakov/DoctrineSolrBundle
By mdiyakov, 1 year ago
-
phpunit tests initial commit
By mdiyakov, 1 year ago
-
composer.json & gitignore
By mdiyakov, 1 year ago
-
fixed null behaviour for fields and filters
By mdiyakov, 1 year ago
-
Update fuzzy_wildcard_range_negative_search.md
By web-flow, 1 year ago
-
Update fuzzy_wildcard_range_negative_search.md
By web-flow, 1 year ago
-
error message
By mdiyakov, 1 year ago
-
composer.json
By mdiyakov, 1 year ago
-
Merge remote-tracking branch 'origin/master'
By mdiyakov, 1 year ago
-
date field, fixed array field
By mdiyakov, 1 year ago
-
Update README.md
By web-flow, 1 year ago
-
Update console.md
By web-flow, 1 year ago
-
Update query_building.md
By web-flow, 1 year ago
-
Update suggestions.md
By web-flow, 1 year ago
-
Update schema_search.md
By web-flow, 1 year ago
-
Update filters.md
By web-flow, 1 year ago
-
Update custom_finder_class.md
By web-flow, 1 year ago
-
Update fuzzy_wildcard_range_negative_search.md
By web-flow, 1 year ago
-
Update fuzzy_wildcard_range_negative_search.md
By web-flow, 1 year ago
-
Update fuzzy_wildcard_range_negative_search.md
By web-flow, 1 year ago
-
Update fuzzy_wildcard_range_negative_search.md
By web-flow, 1 year ago
-
Update fuzzy_wildcard_range_negative_search.md
By web-flow, 1 year ago
-
Update getting_started.md
By web-flow, 1 year ago
-
Update README.md
By web-flow, 1 year ago