diff options
author | Dylan William Hardison <dylan@hardison.net> | 2017-07-20 22:36:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-20 22:36:56 +0200 |
commit | da9c617eb5d8345409386b85b5d8c167fc0c55d7 (patch) | |
tree | 0938a7253553df05d30df952d6fc2b6e1393743b /Bugzilla/User.pm | |
parent | 608ec172071f5adfe8eba9c83d42668520a2baea (diff) | |
download | bugzilla-da9c617eb5d8345409386b85b5d8c167fc0c55d7.tar.gz bugzilla-da9c617eb5d8345409386b85b5d8c167fc0c55d7.tar.xz |
Bug 1381869 - Use separate elasticsearch index for Bugzilla::User
This patch removes the concept of a single, bugzilla-wide index in favor of a
per-class index. bugs and comments continue to use
Bugzilla->params->{elasticsearch_index} but users use
Bugzilla->params->{elasticsearch_index} . "_user".
It is assured via the ChildObject trait (role) that comments will share the
index with bugs, and we have kept the index for bugs/comments the same to avoid
the multi-hour reindexing of production. Re-indexing users takes only five
minutes.
Subsequent work on this will allow use to version the index names and use
aliases, but I wanted to keep this patch small.
This patch also corrects some mistakes
1. $indexer->put_mapping() should not have been a public method.
2. Time::HiRes should be imported at the top of the file, not in a sub.
Diffstat (limited to 'Bugzilla/User.pm')
-rw-r--r-- | Bugzilla/User.pm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 2d7f38640..525733069 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -126,6 +126,11 @@ use constant EXTRA_REQUIRED_FIELDS => qw(is_enabled); with 'Bugzilla::Elastic::Role::Object'; +sub ES_INDEX { + my ($class) = @_; + sprintf("%s_%s", Bugzilla->params->{elasticsearch_index}, $class->ES_TYPE); +} + sub ES_TYPE { 'user' } sub ES_OBJECTS_AT_ONCE { 5000 } @@ -153,6 +158,31 @@ sub ES_SELECT_ALL_SQL { return ("SELECT $id FROM $table WHERE $id > ? AND is_enabled AND NOT disabledtext ORDER BY $id", [$last_id // 0]); } +sub ES_SETTINGS { + return { + number_of_shards => 2, + analysis => { + filter => { + asciifolding_original => { + type => "asciifolding", + preserve_original => \1, + }, + }, + analyzer => { + autocomplete => { + type => 'custom', + tokenizer => 'keyword', + filter => [ 'lowercase', 'asciifolding_original' ], + }, + folding => { + tokenizer => 'standard', + filter => [ 'standard', 'lowercase', 'asciifolding_original' ], + }, + } + } + }; +} + sub ES_PROPERTIES { return { suggest_user => { |