PHP code example of tom-lingham / searchy

1. Go to this page and download the library: Download tom-lingham/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/ */

    

tom-lingham / searchy example snippets


TomLingham\Searchy\SearchyServiceProvider::class

'Searchy' => TomLingham\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();

// 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 = [
  'TomLingham\Searchy\Matchers\ExactMatcher'                 => 100,
  'TomLingham\Searchy\Matchers\StartOfStringMatcher'         => 50,
  'TomLingham\Searchy\Matchers\InStringMatcher'              => 30,
];

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

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