PHPackages                             tapronto/solr-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. tapronto/solr-bundle

ActiveSymfony-bundle[Search &amp; Filtering](/categories/search)

tapronto/solr-bundle
====================

Symfony2 Solr integration bundle

0.2.1(13y ago)2731PHPPHP &gt;=5.3.2

Since Oct 25Pushed 13y ago1 watchersCompare

[ Source](https://github.com/tapronto/SolrBundle)[ Packagist](https://packagist.org/packages/tapronto/solr-bundle)[ Docs](https://github.com/floriansemm/SolrBundle)[ RSS](/packages/tapronto-solr-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

This Bundle provides a simple API to index and query a Solr Index.

Installation
============

[](#installation)

Solr-Server

Follow the installation instructions in this [Tutorial](http://davehall.com.au/blog/dave/2010/06/26/multi-core-apache-solr-ubuntu-1004-drupal-auto-provisioning)

PHP-Extension

```
	sudo pecl install -n solr-beta

```

Bundle

1. Register bundle in AppKernel.php

    ```
    # app/AppKernel.php

    $bundles = array(
        // ...
        new FS\SolrBundle\FSSolrBundle(),
        // ...
    );

    ```
2. Add Bundle to autoload

    ```
    # app/autoload.php

    $loader->registerNamespaces(array(
        // ...
        'FS' => __DIR__.'/../vendor/bundles',
        // ...
    ));

    ```

Configuration
=============

[](#configuration)

You have to setup the connection options

```
	# app/config/config.yml

	fs_solr:
		solr:
			hostname: localhost
			port: 8983
            path:
                core0: /solr/core0
                core1: /solr/core1
        auto_index: true|false
		entity_manager: default

```

Usage
=====

[](#usage)

To put an entity to the index, you must add some annotations to your entity:

```
	// your Entity

	// ....
	use FS\SolrBundle\Doctrine\Annotation as Solr;

	/**
	 *
	 *
	 * @Solr\Document(repository="Full\Qualified\Class\Name")
	 * @ORM\Table()
	 */
	class Post
	{
		/**
		 * @Solr\Id
		 *
		 * @ORM\Column(name="id", type="integer")
		 * @ORM\Id
		 * @ORM\GeneratedValue(strategy="AUTO")
		 */
		private $id;

		/**
		 *
		 * @Solr\Field(type="string")
		 *
		 * @ORM\Column(name="title", type="string", length=255)
		 */
		private $title = '';

		/**
		 *
		 * @Solr\Field(type="string")
		 *
		 * @ORM\Column(name="text", type="text")
		 */
		private $text = '';

		/**
		 * @Solr\Field(type="date")
		 *
		 * @ORM\Column(name="created_at", type="datetime")
		 */
		private $created_at = null;
	}

```

If you persist this entity, it will put automaticlly to the index. Update and delete happens automatically too.

To query the index you have to call some services.

```
	$query = $this->get('solr')->createQuery('AcmeDemoBundle:Post');
	$query->addSearchTerm('title', 'my title');
	$query->addField('id');
	$query->addField('text');

	$result = $query->getResult();

```

The $result array contains all found entities. The solr-service does all mappings from SolrDocument to your entity for you. In this case only the fields id and text will be mapped (addField()), so title and created\_at will be empty. If nothing was found $result is empty.

If no field was explict add, all fields will be mapped.

```
	$query = $this->get('solr')->createQuery('AcmeDemoBundle:Post');
	$query->addSearchTerm('title', 'my title');

	$result = $result = $query->getResult();

```

The pervious examples have queried only the field 'title'. You can also query all fields with a string.

```
	$query = $this->get('solr')->createQuery('AcmeDemoBundle:Post');
	$query->queryAllFields('my title);

	$result = $query->getResult();

```

To index your entities manually, you can do it the following way:

```
	$this->get('solr')->addDocument($entity);
	$this->get('solr')->updateDocument($entity);
	$this->get('solr')->deleteDocument($entity);

```

The delete action needs the id of the entity.

If you specify your own repository you must extend the `FS\SolrBundle\Repository\Repository` class. The useage is the same like Doctrine-Repositories:

```
$myRepository = $this->get('solr')->getRepository('AcmeDemoBundle:Post');
$result = $myRepository->mySpecialFindMethod();

```

If you haven't declared a concrete repository in your entity and you calling `$this->get('solr')->getRepository('AcmeDemoBundle:Post')`, you will get an instance of `FS\SolrBundle\Repository\Repository`.

MongoDB
=======

[](#mongodb)

All this functionality is also avaiable for mongo-db entities. The entity configuration via annotations is absolutly the same.

Use multiple Cores
==================

[](#use-multiple-cores)

Solr supports multiple indexies. If you have different languages in your application, use can index your documents in different indexies.

The setup is easy:

Under the `path` option, you can specify your different indexies.

```
        path:
                core0: /solr/core0
                core1: /solr/core1

```

In this case the default core is `core0`. If you use multiple core, then the auto-index functionality should be disabled. In other case all document will index in one core. To disable use the flag `auto_index` in your config (default value is `true`).

To index documents with the `addDocument` method requires a concrete core:

```
    $this->get('solr')->core('core0')->addDocument($document);

```

Commands
========

[](#commands)

There are comming two commands with this bundle:

- `solr:index:clear` - delete all documents in the index
- `solr:synchronize` - synchronize the db with the index. You have to specify an entity.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

3

Last Release

4943d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9bc459d18dfa252ff320d2c2ef4c8325729e255612d7ee8f87f6df418c3ef363?d=identicon)[ashton](/maintainers/ashton)

---

Top Contributors

[![ashton](https://avatars.githubusercontent.com/u/95974?v=4)](https://github.com/ashton "ashton (1 commits)")[![gigo6000](https://avatars.githubusercontent.com/u/387648?v=4)](https://github.com/gigo6000 "gigo6000 (1 commits)")

---

Tags

searchsymfonyindexsolr

### Embed Badge

![Health badge](/badges/tapronto-solr-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tapronto-solr-bundle/health.svg)](https://phpackages.com/packages/tapronto-solr-bundle)
```

###  Alternatives

[floriansemm/solr-bundle

Symfony Solr integration bundle

12280.2k2](/packages/floriansemm-solr-bundle)[nelmio/solarium-bundle

Integration with solarium solr client.

1493.0M12](/packages/nelmio-solarium-bundle)[jolicode/elastically

Opinionated Elastica based framework to bootstrap PHP and Elasticsearch implementations.

2571.7M1](/packages/jolicode-elastically)[terminal42/escargot

A web crawler or spider library based on Symfony components

581.4M3](/packages/terminal42-escargot)[cmsig/seal-symfony-bundle

An integration of CMS-IG SEAL search abstraction into Symfony Framework.

15195.8k5](/packages/cmsig-seal-symfony-bundle)[cmsig/seal

Search Engine Abstraction Layer

32207.9k53](/packages/cmsig-seal)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
