diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Config/Elastic.pm | 29 | ||||
-rw-r--r-- | Bugzilla/Elastic.pm | 15 | ||||
-rw-r--r-- | Bugzilla/Install.pm | 6 |
3 files changed, 36 insertions, 14 deletions
diff --git a/Bugzilla/Config/Elastic.pm b/Bugzilla/Config/Elastic.pm index 2b2513f1b..690f5fac5 100644 --- a/Bugzilla/Config/Elastic.pm +++ b/Bugzilla/Config/Elastic.pm @@ -16,18 +16,23 @@ use Bugzilla::Config::Common; our $sortkey = 1550; sub get_param_list { - return ( - { - name => 'elasticsearch_nodes', - type => 't', - default => 'localhost:9200', - }, - { - name => 'elasticsearch_index', - type => 't', - default => 'bugzilla', - }, - ); + return ( + { + name => 'elasticsearch', + type => 'b', + default => 0, + }, + { + name => 'elasticsearch_nodes', + type => 't', + default => 'localhost:9200', + }, + { + name => 'elasticsearch_index', + type => 't', + default => 'bugzilla', + }, + ); } 1; diff --git a/Bugzilla/Elastic.pm b/Bugzilla/Elastic.pm index 6384269fd..fa032d2a6 100644 --- a/Bugzilla/Elastic.pm +++ b/Bugzilla/Elastic.pm @@ -16,6 +16,12 @@ with 'Bugzilla::Elastic::Role::HasIndexName'; sub suggest_users { my ($self, $text) = @_; + + unless (Bugzilla->params->{elasticsearch}) { + # optimization: faster than a regular method call. + goto &_suggest_users_fallback; + } + my $field = 'suggest_user'; if ($text =~ /^:(.+)$/) { $text = $1; @@ -38,10 +44,15 @@ sub suggest_users { } else { warn "suggest_users error: $@"; - my $users = Bugzilla::User::match($text, 25, 0); - return [ map { { real_name => $_->name, name => $_->login } } @$users]; + # optimization: faster than a regular method call. + goto &_suggest_users_fallback; } } +sub _suggest_users_fallback { + my ($self, $text) = @_; + my $users = Bugzilla::User::match($text, 25, 0); + return [ map { { real_name => $_->name, name => $_->login } } @$users]; +} 1; diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm index edadbfecb..982f4a4fb 100644 --- a/Bugzilla/Install.pm +++ b/Bugzilla/Install.pm @@ -175,6 +175,12 @@ sub SETTINGS { default => 'off', category => 'API' }, + { + name => 'use_elasticsearch', + options => ['on', 'off'], + default => 'off', + category => 'Searching' + }, ]; }; |