2017 © Pedro Peláez
 

symfony-bundle doctrine-solr-bundle

Symfony 2 bundle for integration Doctrine entities with Solr

image

mdiyakov/doctrine-solr-bundle

Symfony 2 bundle for integration Doctrine entities with Solr

  • Sunday, July 1, 2018
  • by mdiyakov
  • Repository
  • 2 Watchers
  • 11 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 33 % Grown

The README.md

DoctrineSolrBundle

SensioLabsInsight Build Status Latest Stable Version License Scrutinizer Code Quality, (*1)

DoctrineSolrBundle is a Symfony bundle designed to mitigate Solr usage in symfony projects, (*2)

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., (*3)

Step 2

Enable the bundle in the kernel :, (*4)

// 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, (*5)

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:, (*6)

nelmio_solarium: ~

The default solr endpoint will be used in this case (http://localhost:8983/solr), (*7)

Init bundle configuration in config.yml. Quick example:, (*8)

 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., (*9)

If you use doctrine/orm < 2.5 then you have to add an annotation to "AppBundle\Entity\MyEntity" class:, (*10)

@ORM\EntityListeners({"Mdiyakov\DoctrineSolrBundle\EventListener\DoctrineEntityListener"})

To search "AppBundle\Entity\MyEntity" use the following code:, (*11)

// 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

  1. Getting started with DoctrineSolrBundle
  2. Regular, fuzzy, wildcard, range and negative search
  3. Custom finder class
  4. Filters
  5. Schema search across multiple entities classes
  6. Suggestions
  7. Query building
  8. Console command to index entities
  9. Console command to delete entities
  10. EntityManager. How to flush an entity safe
  11. Roadmap

The Versions

01/07 2018

dev-master

9999999-dev

Symfony 2 bundle for integration Doctrine entities with Solr

  Sources   Download

MIT

The Requires

 

The Development Requires

search symfony full-text index solr find

01/07 2018

v1.1.1

1.1.1.0

Symfony 2 bundle for integration Doctrine entities with Solr

  Sources   Download

MIT

The Requires

 

The Development Requires

search symfony full-text index solr find

01/07 2018

v1.1.x-dev

1.1.9999999.9999999-dev

Symfony 2 bundle for integration Doctrine entities with Solr

  Sources   Download

MIT

The Requires

 

The Development Requires

search symfony full-text index solr find

15/04 2018

v1.1.0

1.1.0.0

Symfony 2 bundle for integration Doctrine entities with Solr

  Sources   Download

MIT

The Requires

 

The Development Requires

search symfony full-text index solr find

26/03 2018

v1.0.x-dev

1.0.9999999.9999999-dev

Symfony 2 bundle for integration Doctrine entities with Solr

  Sources   Download

MIT

The Requires

 

The Development Requires

search symfony full-text index solr find

26/03 2018

v1.0.0

1.0.0.0

Symfony 2 bundle for integration Doctrine entities with Solr

  Sources   Download

MIT

The Requires

 

The Development Requires

search symfony full-text index solr find

24/03 2018

v1.0-RC1

1.0.0.0-RC1

Symfony 2 bundle for integration Doctrine entities with Solr

  Sources   Download

MIT

The Requires

 

The Development Requires

search symfony full-text index solr find