diff --git a/config/laravel-search.php b/config/laravel-search.php index 7c0928d..26818ea 100644 --- a/config/laravel-search.php +++ b/config/laravel-search.php @@ -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'), ] -]; \ No newline at end of file +]; diff --git a/src/Engines/ElasticSearchEngine.php b/src/Engines/ElasticSearchEngine.php index d557451..094490d 100644 --- a/src/Engines/ElasticSearchEngine.php +++ b/src/Engines/ElasticSearchEngine.php @@ -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'), ], ] ] @@ -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'), ], ] ] @@ -376,4 +376,4 @@ public function deleteIndex($config) $this->client->indices()->delete($params); } } -} \ No newline at end of file +} diff --git a/src/SearchServiceProvider.php b/src/SearchServiceProvider.php index f3e08f5..be490aa 100644 --- a/src/SearchServiceProvider.php +++ b/src/SearchServiceProvider.php @@ -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. * @@ -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'); + } }