Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fuzziness search defaulted to AUTO #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/laravel-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@

],

'fuzziness' => env('SEARCH_FUZZINESS', 'AUTO'),

'es' => [
'user' => env('SEARCH_USER', ''),
'password' => env('SEARCH_PASSWORD'),
'schema' => env('SEARCH_HOST_SCHEMA'),
'port' => env('SEARCH_HOST_PORT'),
]
];
];
10 changes: 5 additions & 5 deletions src/Engines/ElasticSearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ protected function performSearch(Builder $builder, array $filters = [])
'bool' => [
'must' => [
[
'multi_match' => [
'query_string' => [
'query' => $builder->query,
'fields' => $builder->fields,
'type' => 'phrase',
'operator' => 'and',
'default_operator' => 'and',
'fuzziness' => config('laravel-search.fuzziness'),
],
]
]
Expand Down Expand Up @@ -282,8 +282,8 @@ public function searchAll(AllBuilder $builder)
'query' => [
'query_string' => [
'query' => $builder->query,
'type' => 'phrase',
'default_operator' => 'and',
'fuzziness' => config('laravel-search.fuzziness'),
],
]
]
Expand Down Expand Up @@ -376,4 +376,4 @@ public function deleteIndex($config)
$this->client->indices()->delete($params);
}
}
}
}
26 changes: 26 additions & 0 deletions src/SearchServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ public function register()
});
}

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->configurePublishing();
}

/**
* Get the services provided by the provider.
*
Expand All @@ -51,4 +61,20 @@ public function provides()
{
return ['search'];
}

/**
* Configure publishing for the package.
*
* @return void
*/
protected function configurePublishing()
{
if (!$this->app->runningInConsole()) {
return;
}

$this->publishes([
__DIR__ . '/../config/laravel-search.php' => config_path('laravel-search.php'),
], 'laravel-search-config');
}
}