PHP code example of invision-media / searchy

1. Go to this page and download the library: Download invision-media/searchy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

invision-media / searchy example snippets


InvisionMedia\Searchy\SearchyServiceProvider::class

'Searchy' => InvisionMedia\Searchy\Facades\Searchy::class

$users = Searchy::users('name', 'email')->query('John Smith')->get();

$users = Searchy::search('users')->fields('name', 'email')->query('John Smith')->get();

$users = Searchy::search('users')->fields('name', 'email')->query('John Smith')
    ->getQuery()->having('relevance', '>', 20)->get();

$users = Searchy::search('users')->connection('name_of_connection')->fields('name', 'email')->query('John Smith')
    ->getQuery()->having('relevance', '>', 20)->get();

// Only get the top 10 results
$users = Searchy::search('users')->fields('name', 'email')->query('John Smith')
    ->getQuery()->limit(10)->get();

$users = Searchy::users('name', 'email', 'username')->query('John Smith')->get();

$users = Searchy::users(['name', 'email', 'username'])->query('John Smith')->get();

$users = Searchy::users('first_name::last_name')->query('John Smith')->get();

Searchy::users('name')->withTrashed()->query('Batman')->get();

$users = Searchy::users('first_name::last_name')->query('John Smith')->select('first_name')->get();

// Or you can swap those around...
$users = Searchy::users('first_name::last_name')->select('first_name')->query('John Smith')->get();

\App\User::hydrate(Searchy::users('name', 'email')->query('Andrew')->get());


return [

    'default' => 'ufuzzy',

  ...
]


Searchy::driver('fuzzy')->users('name')->query('Batman')->get();

protected $matchers = [
  'InvisionMedia\Searchy\Matchers\ExactMatcher'                 => 100,
  'InvisionMedia\Searchy\Matchers\StartOfStringMatcher'         => 50,
  'InvisionMedia\Searchy\Matchers\InStringMatcher'              => 30,
];

protected $matchers = [
  'InvisionMedia\Searchy\Matchers\ExactMatcher'                 => 100,
  'InvisionMedia\Searchy\Matchers\StartOfStringMatcher'         => 50,
  'InvisionMedia\Searchy\Matchers\AcronymMatcher'               => 42,
  'InvisionMedia\Searchy\Matchers\ConsecutiveCharactersMatcher' => 40,
  'InvisionMedia\Searchy\Matchers\StartOfWordsMatcher'          => 35,
  'InvisionMedia\Searchy\Matchers\StudlyCaseMatcher'            => 32,
  'InvisionMedia\Searchy\Matchers\InStringMatcher'              => 30,
  'InvisionMedia\Searchy\Matchers\TimesInStringMatcher'         => 8,
];

protected $matchers = [
  'InvisionMedia\Searchy\Matchers\LevenshteinMatcher' => 100
];