2017 © Pedro Peláez
 

library sphinxsearch

Laravel package to query Sphinxsearch in Laravel 5

image

iris/sphinxsearch

Laravel package to query Sphinxsearch in Laravel 5

  • Wednesday, November 22, 2017
  • by iris-xie
  • Repository
  • 2 Watchers
  • 0 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 48 Forks
  • 0 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

Sphinx Search for Laravel 5 - Custom build with snippets support

Simple Laravel 5 package for make queries to Sphinx Search. Inspired by scalia/sphinxsearch package for Laravel 4., (*1)

This package was created to import to the site packagist.org and allow installation through Composer (https://getcomposer.org/)., (*2)

Installation

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

    "require": {
        /*** Some others packages ***/
        "sngrl/sphinxsearch": "dev-master",
    },

Run in your console composer update command to pull down the latest version of Sphinx Search., (*4)

Or just run this in console:, (*5)

composer require sngrl/sphinxsearch:dev-master

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

    'providers' => array(
        /*** Some others providers ***/
        Iris\SphinxSearch\SphinxSearchServiceProvider::class,
    ),

You can add this line to the files, where you may use SphinxSearch:, (*7)

use Iris\SphinxSearch\SphinxSearch;

Configuration

To use Sphinx Search, you need to configure your indexes and what model it should query. To do so, publish the configuration into your app., (*8)

php artisan vendor:publish --provider=Iris\SphinxSearch\SphinxSearchServiceProvider --force

This will create the file config/sphinxsearch.php. Modify as needed the host and port, and configure the indexes, binding them to a table and id column., (*9)

return array (
    'host'    => '127.0.0.1',
    'port'    => 9312,
    'indexes' => array (
        'my_index_name' => array ( 'table' => 'my_keywords_table', 'column' => 'id' ),
    )
);

Or disable the model querying to just get a list of result id's., (*10)

return array (
    'host'    => '127.0.0.1',
    'port'    => 9312,
    'indexes' => array (
        'my_index_name' => FALSE,
    )
);

Usage

Basic query (raw sphinx results), (*11)

$sphinx = new SphinxSearch();
$results = $sphinx->search('my query', 'index_name')->query();

Basic query (with Eloquent), (*12)

$results = $sphinx->search('my query', 'index_name')->get();

Query another Sphinx index with limit and filters., (*13)

$results = $sphinx->search('my query', 'index_name')
    ->limit(30)
    ->filter('attribute', array(1, 2))
    ->range('int_attribute', 1, 10)
    ->get();

Query with match and sort type specified., (*14)

$result = $sphinx->search('my query', 'index_name')
    ->setFieldWeights(
        array(
            'partno'  => 10,
            'name'    => 8,
            'details' => 1
        )
    )
    ->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_EXTENDED)
    ->setSortMode(\Sphinx\SphinxClient::SPH_SORT_EXTENDED, "@weight DESC")
    ->get(true);  //passing true causes get() to respect returned sort order

License

Sngrl Sphinx Search is open-sourced software licensed under the MIT license, (*15)

The Versions

22/11 2017

dev-master

9999999-dev

Laravel package to query Sphinxsearch in Laravel 5

  Sources   Download

MIT

The Requires

 

by Avatar Sngrl

laravel laravel 5 sphinx sphinxsearch

22/11 2017

0.3.2

0.3.2.0

Laravel package to query Sphinxsearch in Laravel 5

  Sources   Download

MIT

The Requires

 

by Avatar Sngrl

laravel laravel 5 sphinx sphinxsearch

22/11 2017

0.3.1

0.3.1.0

Laravel package to query Sphinxsearch in Laravel 5

  Sources   Download

MIT

The Requires

 

by Avatar Sngrl

laravel laravel 5 sphinx sphinxsearch

22/11 2017

0.2.0

0.2.0.0 http://github.com/sngrl/sphinxsearch

Laravel package to query Sphinxsearch in Laravel 5

  Sources   Download

Apache-2.0

The Requires

 

by Avatar Sngrl

laravel laravel 5 sphinx sphinxsearch

22/11 2017

0.1.0

0.1.0.0 http://github.com/sngrl/sphinxsearch

Laravel package to query Sphinxsearch in Laravel 5

  Sources   Download

Apache-2.0

The Requires

 

by Avatar Sngrl

laravel laravel 5 sphinx sphinxsearch