Beispiel #1
0
        private string _createCommand(string command, AliasParams aliasParam)
        {
            var cmd = @"{{ ""{0}"" : {{
				index: ""{1}"",
				alias: ""{2}"""                .F(command, aliasParam.Index, aliasParam.Alias);

            if (!aliasParam.Filter.IsNullOrEmpty())
            {
                cmd += @", ""filter"": {0} ".F(aliasParam.Filter);
            }

            if (!aliasParam.Routing.IsNullOrEmpty())
            {
                cmd += @", ""routing"": ""{0}"" ".F(aliasParam.Routing);
            }
            else
            {
                if (!aliasParam.IndexRouting.IsNullOrEmpty())
                {
                    cmd += @", ""index_routing"": ""{0}"" ".F(aliasParam.IndexRouting);
                }
                if (!aliasParam.SearchRouting.IsNullOrEmpty())
                {
                    cmd += @", ""search_routing"": ""{0}"" ".F(aliasParam.SearchRouting);
                }
            }
            cmd += "} }";

            return(cmd);
        }
Beispiel #2
0
        /// <summary>
        /// Repoint an alias from a set of old indices to a set of new indices in one operation
        /// </summary>
        public IIndicesOperationResponse Swap(AliasParams aliasParam, IEnumerable <string> oldIndices, IEnumerable <string> newIndices)
        {
            var commands = new List <string>();

            foreach (var i in oldIndices)
            {
                commands.Add(_createCommand("remove", new AliasParams {
                    Index = i, Alias = aliasParam.Alias
                }));
            }
            foreach (var i in newIndices)
            {
                aliasParam.Index = i;
                commands.Add(_createCommand("add", aliasParam));
            }
            return(this._Alias(string.Join(", ", commands)));
        }
Beispiel #3
0
 /// <summary>
 /// Freeform remove alias overload for complete control of all the aspects
 /// </summary>
 public IIndicesOperationResponse RemoveAlias(AliasParams aliasParams)
 {
     return(this._Alias(_createCommand("remove", aliasParams)));
 }
 /// <summary>
 /// Freeform alias overload for complete control of all the aspects (does an add operation)
 /// </summary>
 public IndicesOperationResponse Alias(AliasParams aliasParams)
 {
     return this._Alias(_createCommand("add", aliasParams));
 }
        private string _createCommand(string command, AliasParams aliasParam)
        {
            var cmd  = @"{{ ""{0}"" : {{
                index: ""{1}"",
                alias: ""{2}""".F(command, aliasParam.Index, aliasParam.Alias);

            if (!aliasParam.Filter.IsNullOrEmpty())
                cmd += @", ""filter"": {0} ".F(aliasParam.Filter);

            if (!aliasParam.Routing.IsNullOrEmpty())
                cmd += @", ""routing"": ""{0}"" ".F(aliasParam.Routing);
            else
            {
                if (!aliasParam.IndexRouting.IsNullOrEmpty())
                    cmd += @", ""index_routing"": ""{0}"" ".F(aliasParam.IndexRouting);
                if (!aliasParam.SearchRouting.IsNullOrEmpty())
                    cmd += @", ""search_routing"": ""{0}"" ".F(aliasParam.SearchRouting);
            }
            cmd += "} }";

            return cmd;
        }
Beispiel #6
0
 /// <summary>
 /// Freeform remove alias overload for complete control of all the aspects
 /// </summary>
 public IIndicesOperationResponse RemoveAlias(AliasParams aliasParams)
 {
     return this._Alias(_createCommand("remove", aliasParams));
 }
Beispiel #7
0
 public IndicesOperationResponse Alias(AliasParams aliasParams)
 {
     return(this._Alias(_createCommand("add", aliasParams)));
 }
 /// <summary>
 /// Repoint an alias from a set of old indices to a set of new indices in one operation
 /// </summary>
 public IIndicesOperationResponse Swap(AliasParams aliasParam, IEnumerable<string> oldIndices, IEnumerable<string> newIndices)
 {
     var commands = new List<string>();
     foreach (var i in oldIndices)
         commands.Add(_createCommand("remove", new AliasParams { Index = i, Alias = aliasParam.Alias }));
     foreach (var i in newIndices)
     {
         aliasParam.Index = i;
         commands.Add(_createCommand("add", aliasParam));
     }
     return this._Alias(string.Join(", ", commands));
 }