Documentation ¶
Index ¶
- Constants
- Variables
- func GetAliasIndexMap(ctx context.Context) (map[string]string, error)
- func InitAliasIndexCache()
- func InitIndexAliasCache()
- func IsReIndexInProcess(source, destination string) bool
- func IsTaskCompleted(ctx context.Context, taskID string) (bool, error)
- func Reindex(ctx context.Context, sourceIndex string, config *ReindexConfig, ...) ([]byte, error)
- func RemoveCurrentProcess(taskID string)
- func SetAlias(aliasConfig SetAliasConfig) error
- func SetCurrentProcess(taskID, source, destination string)
- func TrackReindex(aliasConfig SetAliasConfig, taskDetails []byte)
- type Action
- type AliasedIndices
- type ReIndexOperation
- type ReindexConfig
- type SetAliasConfig
- type TaskResponseFailure
- type TaskResponseStruct
Constants ¶
const IndexStoreSize = int64(100000000)
IndexStoreSize to decide whether to use async or sync re-indexing
Variables ¶
var CurrentlyReIndexingProcess = make(map[string][]string)
CurrentlyReIndexingProcess map of taskID [source, destinations] indexes for which indexing process is going on
var CurrentlyReIndexingProcessMutex = sync.RWMutex{}
CurrentlyReIndexingProcessMutex to stop concurrent writes on map
Functions ¶
func InitAliasIndexCache ¶
func InitAliasIndexCache()
InitAliasIndexCache to set alias -> index cache on initialization
func InitIndexAliasCache ¶
func InitIndexAliasCache()
InitIndexAliasCache to set cache on ReactiveSearch initialization
func IsReIndexInProcess ¶
IsReIndexInProcess check if index is Processing currently
func IsTaskCompleted ¶
To track a re-index task by taskID
func Reindex ¶
func Reindex(ctx context.Context, sourceIndex string, config *ReindexConfig, waitForCompletion bool, destinationIndex string) ([]byte, error)
Reindex Inplace: https://www.elastic.co/guide/en/elasticsearch/reference/current/reindex-upgrade-inplace.html
- Create a new index and copy the mappings and settings from the old index.
- Set the refresh_interval to -1 and the number_of_replicas to 0 for efficient reindexing.
- Reindex all documents from the old index into the new index using the reindex API.
- Reset the refresh_interval and number_of_replicas to the values used in the old index.
- Wait for the index status to change to green.
- In a single update aliases request: a. Delete the old index. b. Add an alias with the old index name to the new index. c. Add any aliases that existed on the old index to the new index.
We accept a query param `wait_for_completion` which defaults to true, which when false, we don't create any aliases and delete the old index, we instead return the tasks API response.
func RemoveCurrentProcess ¶
func RemoveCurrentProcess(taskID string)
RemoveCurrentProcess remove indexes for current reindexing process
func SetCurrentProcess ¶
func SetCurrentProcess(taskID, source, destination string)
SetCurrentProcess set indexes for current reindexing process
func TrackReindex ¶
func TrackReindex(aliasConfig SetAliasConfig, taskDetails []byte)
To track reindex process. Use it in a go routine to track asynchronously.
Types ¶
type AliasedIndices ¶
type AliasedIndices struct { Alias string `json:"alias"` Health string `json:"health"` Status string `json:"status"` Index string `json:"index"` UUID string `json:"uuid"` Pri interface{} `json:"pri"` Rep interface{} `json:"rep"` DocsCount interface{} `json:"docs.count"` DocsDeleted interface{} `json:"docs.deleted"` StoreSize string `json:"store.size"` PriStoreSize string `json:"pri.store.size"` }
AliasedIndices struct
func GetAliasedIndices ¶
func GetAliasedIndices(ctx context.Context) ([]AliasedIndices, error)
type ReIndexOperation ¶
type ReIndexOperation int
const ( ReIndexWithDelete ReIndexOperation = iota ReindexWithClone )
func (ReIndexOperation) String ¶
func (o ReIndexOperation) String() string
type ReindexConfig ¶
type ReindexConfig struct { Mappings map[string]interface{} `json:"mappings"` Settings map[string]interface{} `json:"settings"` SearchRelevancySettings *map[string]interface{} `json:"search_relevancy_settings"` Include []string `json:"include_fields"` Exclude []string `json:"exclude_fields"` Types []string `json:"types"` Action []string `json:"action,omitempty"` Script string `json:"script"` }
type SetAliasConfig ¶
type TaskResponseFailure ¶
type TaskResponseFailure struct { Index string `json:"index"` Type string `json:"type"` ID string `json:"id"` Status int32 `json:"status"` Cause struct { Type string `json:"type"` Reason string `json:"reason"` CausedBy struct { Type string `json:"type"` Reason string `json:"reason"` } `json:"caused_by"` } `json:"cause"` }
type TaskResponseStruct ¶
type TaskResponseStruct struct { Completed bool `json:"completed"` Response struct { Failures []TaskResponseFailure `json:"failures"` } `json:"response"` }