MM-63298: [AI assisted] Elasticsearch add a global search prefix (#30417)
This PR adds functionality to search by a global search prefix. This allows Mattermost to be used across multiple data centers with multiple Elasticsearch instances synchronized using cross-cluster replication. While here, we also add tests cases to cover for some missing search interface methods. For now, no system console setting is exposed. Because IndexPrefix is also not exposed. It can be added later if a need arises. https://mattermost.atlassian.net/browse/MM-63298 ```release-note A new config setting ElasticsearchSettings.GlobalSearchPrefix is added which can be used to search across multiple indices having a common prefix. This is useful in a scenario with multiple Elasticsearch instances, where multiple instances are writing to different indices with different prefixes using the ElasticsearchSettings.IndexPrefix setting. ``` Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7250095f86
Коммит
09488558a0
@@ -2916,6 +2916,7 @@ type ElasticsearchSettings struct {
|
||||
AggregatePostsAfterDays *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
PostsAggregatorJobStartTime *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"` // telemetry: none
|
||||
IndexPrefix *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
||||
GlobalSearchPrefix *string `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
||||
LiveIndexingBatchSize *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
||||
BulkIndexingTimeWindowSeconds *int `json:",omitempty"` // telemetry: none
|
||||
BatchSize *int `access:"environment_elasticsearch,write_restrictable,cloud_restrictable"`
|
||||
@@ -3009,6 +3010,10 @@ func (s *ElasticsearchSettings) SetDefaults() {
|
||||
s.IndexPrefix = NewPointer(ElasticsearchSettingsDefaultIndexPrefix)
|
||||
}
|
||||
|
||||
if s.GlobalSearchPrefix == nil {
|
||||
s.GlobalSearchPrefix = NewPointer("")
|
||||
}
|
||||
|
||||
if s.LiveIndexingBatchSize == nil {
|
||||
s.LiveIndexingBatchSize = NewPointer(ElasticsearchSettingsDefaultLiveIndexingBatchSize)
|
||||
}
|
||||
@@ -4427,6 +4432,16 @@ func (s *ElasticsearchSettings) isValid() *AppError {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.invalid_backend.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.GlobalSearchPrefix != "" && *s.IndexPrefix == "" {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.empty_index_prefix.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if *s.GlobalSearchPrefix != "" && *s.IndexPrefix != "" {
|
||||
if !strings.HasPrefix(*s.IndexPrefix, *s.GlobalSearchPrefix) {
|
||||
return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.incorrect_search_prefix.app_error", map[string]any{"IndexPrefix": *s.IndexPrefix, "GlobalSearchPrefix": *s.GlobalSearchPrefix}, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user