Skip to content

Commit

Permalink
switch to algolia/scout-extended
Browse files Browse the repository at this point in the history
  • Loading branch information
Gummibeer committed Apr 22, 2021
1 parent d9af3b7 commit 486ba90
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 6 deletions.
170 changes: 170 additions & 0 deletions algolia/scout-local-users.php
@@ -0,0 +1,170 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Searchable Attributes
|--------------------------------------------------------------------------
|
| Limits the scope of a search to the attributes listed in this setting. Defining
| specific attributes as searchable is critical for relevance because it gives
| you direct control over what information the search engine should look at.
|
| Supported: Null, Array
| Example: ["name", "email", "unordered(city)"]
|
*/

'searchableAttributes' => ['name', 'display_name'],

/*
|--------------------------------------------------------------------------
| Custom Ranking
|--------------------------------------------------------------------------
|
| Custom Ranking is about leveraging business metrics to effectively rank search
| results - it's crucial for any successful search experience. Make sure that
| only "numeric" attributes are used, such as the number of sales or views.
|
| Supported: Null, Array
| Examples: ['desc(comments_count)', 'desc(views_count)']
|
*/

'customRanking' => null,

/*
|--------------------------------------------------------------------------
| Remove Stop Words
|--------------------------------------------------------------------------
|
| Stop word removal is useful when you have a query in natural language, e.g.
| “what is a record?”. In that case, the engine will remove “what”, “is”,
| before executing the query, and therefore just search for “record”.
|
| Supported: Null, Boolean, Array
|
*/

'removeStopWords' => null,

/*
|--------------------------------------------------------------------------
| Disable Typo Tolerance
|--------------------------------------------------------------------------
|
| Algolia provides robust "typo-tolerance" out-of-the-box. This parameter accepts an
| array of attributes for which typo-tolerance should be disabled. This is useful,
| for example, products that might require SKU search without "typo-tolerance".
|
| Supported: Null, Array
| Example: ['id', 'sku', 'reference', 'code']
|
*/

'disableTypoToleranceOnAttributes' => null,

/*
|--------------------------------------------------------------------------
| Attributes For Faceting
|--------------------------------------------------------------------------
|
| Your index comes with no categories. By designating an attribute as a facet, this enables
| Algolia to compute a set of possible values that can later be used to create categories
| or filters. You can also get a count of records that match those values.
|
| Supported: Null, Array
| Example: ['type', 'filterOnly(country)', 'searchable(city)',]
|
*/

'attributesForFaceting' => null,

/*
|--------------------------------------------------------------------------
| Unretrievable Attributes
|--------------------------------------------------------------------------
|
| This is particularly important for security or business reasons, where some attributes are
| used only for ranking or other technical purposes, but should never be seen by your end
| users, such as: total_sales, permissions, stock_count, and other private information.
|
| Supported: Null, Array
| Example: ['total_sales', 'permissions', 'stock_count',]
|
*/

'unretrievableAttributes' => null,

/*
|--------------------------------------------------------------------------
| Ignore Plurals
|--------------------------------------------------------------------------
|
| Treats singular, plurals, and other forms of declensions as matching terms. When
| enabled, will make the engine consider “car” and “cars”, or “foot” and “feet”,
| equivalent. This is used in conjunction with the "queryLanguages" setting.
|
| Supported: Null, Boolean, Array
|
*/

'ignorePlurals' => null,

/*
|--------------------------------------------------------------------------
| Query Languages
|--------------------------------------------------------------------------
|
| Sets the languages to be used by language-specific settings such as
| "removeStopWords" or "ignorePlurals". For optimum relevance, it is
| recommended to only enable languages that are used in your data.
|
| Supported: Null, Array
| Example: ['en', 'fr',]
|
*/

'queryLanguages' => ['en'],

/*
|--------------------------------------------------------------------------
| Distinct
|--------------------------------------------------------------------------
|
| Using this attribute, you can limit the number of returned records that contain the same
| value in that attribute. For example, if the distinct attribute is the series_name and
| several hits (Episodes) have the same value for series_name (Laravel From Scratch).
|
| Supported(distinct): Boolean
| Supported(attributeForDistinct): Null, String
| Example(attributeForDistinct): 'slug'
*/

'distinct' => null,
'attributeForDistinct' => null,

/*
|--------------------------------------------------------------------------
| Other Settings
|--------------------------------------------------------------------------
|
| The easiest way to manage your settings is usually to go to your Algolia dashboard because
| it has a nice UI and you can test the relevancy directly there. Once you fine-tuned your
| configuration, just use the command `scout:sync` to get remote settings in this file.
|
*/
'allowTyposOnNumericTokens' => false,
'exactOnSingleWordQuery' => 'word',
'ranking' => [
'exact',
'typo',
'geo',
'words',
'filters',
'proximity',
'attribute',
'custom',
],
];
170 changes: 170 additions & 0 deletions algolia/scout-prod-users.php
@@ -0,0 +1,170 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Searchable Attributes
|--------------------------------------------------------------------------
|
| Limits the scope of a search to the attributes listed in this setting. Defining
| specific attributes as searchable is critical for relevance because it gives
| you direct control over what information the search engine should look at.
|
| Supported: Null, Array
| Example: ["name", "email", "unordered(city)"]
|
*/

'searchableAttributes' => ['name', 'display_name'],

/*
|--------------------------------------------------------------------------
| Custom Ranking
|--------------------------------------------------------------------------
|
| Custom Ranking is about leveraging business metrics to effectively rank search
| results - it's crucial for any successful search experience. Make sure that
| only "numeric" attributes are used, such as the number of sales or views.
|
| Supported: Null, Array
| Examples: ['desc(comments_count)', 'desc(views_count)']
|
*/

'customRanking' => null,

/*
|--------------------------------------------------------------------------
| Remove Stop Words
|--------------------------------------------------------------------------
|
| Stop word removal is useful when you have a query in natural language, e.g.
| “what is a record?”. In that case, the engine will remove “what”, “is”,
| before executing the query, and therefore just search for “record”.
|
| Supported: Null, Boolean, Array
|
*/

'removeStopWords' => null,

/*
|--------------------------------------------------------------------------
| Disable Typo Tolerance
|--------------------------------------------------------------------------
|
| Algolia provides robust "typo-tolerance" out-of-the-box. This parameter accepts an
| array of attributes for which typo-tolerance should be disabled. This is useful,
| for example, products that might require SKU search without "typo-tolerance".
|
| Supported: Null, Array
| Example: ['id', 'sku', 'reference', 'code']
|
*/

'disableTypoToleranceOnAttributes' => null,

/*
|--------------------------------------------------------------------------
| Attributes For Faceting
|--------------------------------------------------------------------------
|
| Your index comes with no categories. By designating an attribute as a facet, this enables
| Algolia to compute a set of possible values that can later be used to create categories
| or filters. You can also get a count of records that match those values.
|
| Supported: Null, Array
| Example: ['type', 'filterOnly(country)', 'searchable(city)',]
|
*/

'attributesForFaceting' => null,

/*
|--------------------------------------------------------------------------
| Unretrievable Attributes
|--------------------------------------------------------------------------
|
| This is particularly important for security or business reasons, where some attributes are
| used only for ranking or other technical purposes, but should never be seen by your end
| users, such as: total_sales, permissions, stock_count, and other private information.
|
| Supported: Null, Array
| Example: ['total_sales', 'permissions', 'stock_count',]
|
*/

'unretrievableAttributes' => null,

/*
|--------------------------------------------------------------------------
| Ignore Plurals
|--------------------------------------------------------------------------
|
| Treats singular, plurals, and other forms of declensions as matching terms. When
| enabled, will make the engine consider “car” and “cars”, or “foot” and “feet”,
| equivalent. This is used in conjunction with the "queryLanguages" setting.
|
| Supported: Null, Boolean, Array
|
*/

'ignorePlurals' => null,

/*
|--------------------------------------------------------------------------
| Query Languages
|--------------------------------------------------------------------------
|
| Sets the languages to be used by language-specific settings such as
| "removeStopWords" or "ignorePlurals". For optimum relevance, it is
| recommended to only enable languages that are used in your data.
|
| Supported: Null, Array
| Example: ['en', 'fr',]
|
*/

'queryLanguages' => ['en'],

/*
|--------------------------------------------------------------------------
| Distinct
|--------------------------------------------------------------------------
|
| Using this attribute, you can limit the number of returned records that contain the same
| value in that attribute. For example, if the distinct attribute is the series_name and
| several hits (Episodes) have the same value for series_name (Laravel From Scratch).
|
| Supported(distinct): Boolean
| Supported(attributeForDistinct): Null, String
| Example(attributeForDistinct): 'slug'
*/

'distinct' => null,
'attributeForDistinct' => null,

/*
|--------------------------------------------------------------------------
| Other Settings
|--------------------------------------------------------------------------
|
| The easiest way to manage your settings is usually to go to your Algolia dashboard because
| it has a nice UI and you can test the relevancy directly there. Once you fine-tuned your
| configuration, just use the command `scout:sync` to get remote settings in this file.
|
*/
'allowTyposOnNumericTokens' => false,
'exactOnSingleWordQuery' => 'word',
'ranking' => [
'exact',
'typo',
'geo',
'words',
'filters',
'proximity',
'attribute',
'custom',
],
];
6 changes: 2 additions & 4 deletions app/Console/Kernel.php
Expand Up @@ -2,6 +2,7 @@

namespace App\Console;

use Algolia\ScoutExtended\Console\Commands\ReImportCommand;
use App\Console\Commands\GithubOrganizationDetails;
use App\Console\Commands\GithubOrganizationRepositories;
use App\Console\Commands\GithubRepositoryContributors;
Expand Down Expand Up @@ -37,10 +38,7 @@ protected function schedule(Schedule $schedule): void
$schedule->command(SnapshotCommand::class)->everyFiveMinutes()->onOneServer()->environments('gorgeous-moon');

// laravel/scout
$schedule->command(FlushCommand::class, [User::class])
->dailyAt('02:00')
->onOneServer()
->onSuccess(fn () => $this->call(ImportCommand::class, ['model' => User::class]));
$schedule->command(ReImportCommand::class)->dailyAt('02:00')->onOneServer();

// spatie/laravel-schedule-monitor
$schedule->command(CleanLogCommand::class)->dailyAt('01:00')->onOneServer();
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Expand Up @@ -9,7 +9,7 @@
"ext-intl": "*",
"ext-json": "*",
"ext-redis": "*",
"algolia/algoliasearch-client-php": "^3.0",
"algolia/scout-extended": "^1.17",
"astrotomic/laravel-cachable-attributes": "^0.3.0",
"astrotomic/laravel-imgix": "^0.2.0",
"astrotomic/php-open-graph": "^0.5.2",
Expand All @@ -23,7 +23,6 @@
"laravel/framework": "^8.12",
"laravel/horizon": "^5.7",
"laravel/nova": "^3.22",
"laravel/scout": "^8.6",
"laravel/socialite": "^5.2",
"lorisleiva/cron-translator": "^0.2.0",
"mazedlx/laravel-feature-policy": "^1.1",
Expand Down
1 change: 1 addition & 0 deletions config/scout.php
Expand Up @@ -121,6 +121,7 @@
'id' => env('ALGOLIA_APP_ID'),
'secret' => env('ALGOLIA_SECRET'),
'search_key' => env('ALGOLIA_SEARCH_KEY'),
'settings_path' => realpath(__DIR__.'/../algolia'),
],

];

0 comments on commit 486ba90

Please sign in to comment.