示例#1
0
        public async Task <AliasResponse> AliasAsync(AliasRequest request)
        {
            string url      = request.GetUrl(_clusterUrl);
            var    response = await SendAsync(url, HttpMethod.Post, request.GetBody());

            return(new AliasResponse(response));
        }
示例#2
0
        public void SwapIndex(DateTime scheduledRefreshDateTime)
        {
            _logger.Debug("Swapping vacancy search index for date: {0}", scheduledRefreshDateTime);

            var indexAlias   = GetIndexAlias();
            var newIndexName = GetIndexNameAndDateExtension(indexAlias, scheduledRefreshDateTime);
            var client       = _elasticsearchClientFactory.GetElasticClient();

            _logger.Debug("Swapping vacancy search index alias to new index: {0}", newIndexName);

            var existingIndexesOnAlias = client.GetIndicesPointingToAlias(indexAlias);
            var aliasRequest           = new AliasRequest {
                Actions = new List <IAliasAction>()
            };

            foreach (var existingIndexOnAlias in existingIndexesOnAlias)
            {
                aliasRequest.Actions.Add(new AliasRemoveAction {
                    Remove = new AliasRemoveOperation {
                        Alias = indexAlias, Index = existingIndexOnAlias
                    }
                });
            }

            aliasRequest.Actions.Add(new AliasAddAction {
                Add = new AliasAddOperation {
                    Alias = indexAlias, Index = newIndexName
                }
            });
            client.Alias(aliasRequest);

            _logger.Debug("Swapped vacancy search index alias to new index: {0}", newIndexName);
        }
		public AliasRequestTests()
		{
			var request = new AliasRequest()
			{
				Actions = new List<IAliasAction>
				{
					new AliasAddAction { Add = new AliasAddOperation { Index = "myindex-2014-2-2", Alias = "myindex"}},
					new AliasRemoveAction() { Remove = new AliasRemoveOperation() { Index = "myindex-2014-3-2", Alias = "myindex"}},
				}
			};
			var response = this._client.Alias(request);
			this._status = response.ConnectionStatus;
		}
示例#4
0
        public AliasRequestTests()
        {
            var request = new AliasRequest()
            {
                Actions = new List <IAliasAction>
                {
                    new AliasAddAction {
                        Add = new AliasAddOperation {
                            Index = "myindex-2014-2-2", Alias = "myindex"
                        }
                    },
                    new AliasRemoveAction()
                    {
                        Remove = new AliasRemoveOperation()
                        {
                            Index = "myindex-2014-3-2", Alias = "myindex"
                        }
                    },
                }
            };
            var response = this._client.Alias(request);

            this._status = response.ConnectionStatus;
        }