2017 © Pedro Peláez
 

library solrio

Laravel 5.1 package for full-text search over Eloquent models based on Solarium

image

irto/solrio

Laravel 5.1 package for full-text search over Eloquent models based on Solarium

  • Wednesday, January 13, 2016
  • by Irto
  • Repository
  • 2 Watchers
  • 4 Stars
  • 26 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

solrio

Latest Stable Version Latest Unstable Version License, (*1)

Laravel 5.1 package for full-text search over Eloquent models based on Solarium, inspired by Laravel Lucene Search, (*2)

Installation

Require this package in your composer.json and run composer update:, (*3)

    {
        "require": {
            "irto/solrio": "0.*"
        }
    }

After updating composer, add the ServiceProvider to the providers array in app/config/app.php, (*4)

    'providers' => [
        Irto\Solrio\ServiceProvider::class,
    ],

If you want to use the facade to search, add this to your facades in app/config/app.php:, (*5)

    'aliases' => [
        'Search' => Irto\Solrio\Facade::class,
    ],

Configuration

Publish the config file into your project by running:, (*6)

    php artisan vendor:publish --provider="Irto\Solrio\ServiceProvider"

In published config file add descriptions for models which need to be indexed, for example:, (*7)

    'index' => [

        'models' => [

            // ...

            namespace\FirstModel::class => [
                'fields' => [
                    'name', 'full_description', // Fields for indexing.
                ]
            ],

            namespace\SecondModel::class => [
                'fields' => [
                    'name', 'short_description', // Fields for indexing.
                ]
            ],

            // ...

        ],
    ],

Usage

Artisan commands

Build/Rebuild search index

For building of search index run:, (*8)

    php artisan search:rebuild

Clear search index

For clearing of search index run:, (*9)

    php artisan search:clear

Partial updating of search index

For register of necessary events (save/update/delete) use Irto\Solrio\Model\SearchTrait in target model:, (*10)

    use Illuminate\Database\Eloquent\Model;

    use Irto\Solrio\Model\Searchable;
    use Irto\Solrio\Model\SearchTrait;

    class Dummy extends Model implements Searchable // use of Searchable is optional, without this will be always available to search
    {
        use SearchTrait;

        /**
         * Is the model available for searching?
         */
        public function isSearchable()
        {
            return $this->publish;
        }
    }

You can also do it manually, how on a queued listener:, (*11)

    use Illuminate\Queue\InteractsWithQueue;
    use Illuminate\Contracts\Queue\ShouldQueue;

    use Search; // if alias is configured

    class DummyUpdatedListener extends ShouldQueue
    {
        use InteractsWithQueue;

        public function handle($event)
        {
            $model = $event->getModel();

            Search::update($model); // you can use 'App::offsetGet('search')->update($model);' instead
        }
    }

The Versions

13/01 2016

dev-master

9999999-dev

Laravel 5.1 package for full-text search over Eloquent models based on Solarium

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Israel Trindade

27/10 2015

v0.1.0-alpha5

0.1.0.0-alpha5

Laravel 5.1 package for full-text search over Eloquent models based on Solarium

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Israel Trindade

07/08 2015

v0.1.0-alpha4

0.1.0.0-alpha4

Laravel 5.1 package for full-text search over Eloquent models based on Solarium

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Israel Trindade

05/08 2015

v0.1.0-alpha3

0.1.0.0-alpha3

Laravel 5.1 package for full-text search over Eloquent models based on Solarium

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Israel Trindade

04/08 2015

v0.1.0-alpha2

0.1.0.0-alpha2

Laravel 5.1 package for full-text search over Eloquent models based on Solarium

  Sources   Download

GPL v2

The Requires

 

The Development Requires

by Israel Trindade

02/08 2015

v0.1.0-alpha1

0.1.0.0-alpha1

Laravel 5.1 package for full-text search over Eloquent models based on Solarium

  Sources   Download

GPL v2

The Requires

 

The Development Requires

by Israel Trindade