public List <Item> RandomItems()
        {
            SearchClient         client        = new SearchClient("BIW6EL1FTD", "a5af55b1831c11747c108cc179f2d790");
            SearchIndex          index         = client.InitIndex("Items");
            IndexIterator <Item> indexIterator = index.Browse <Item>(new BrowseIndexQuery {
            });

            var hits = new List <Item>();

            int max = 0;

            foreach (var hit in indexIterator)
            {
                if (hit.ImageURL != "null")
                {
                    hits.Add(hit);
                }

                if (max > 100)
                {
                    break;
                }
                else
                {
                    max++;
                }
            }
            Random rnd = new Random();

            return(hits.Where(t => t.ImageURL.ToLower() != "null").OrderBy(x => rnd.Next()).Take(20).ToList());
        }
        public void MaxValueIsCorrectWhenCurrentValueInGaps()
        {
            HashSet<int> gaps = new HashSet<int>(new List<int> { 2 });
            IndexIterator ii = new IndexIterator(gaps, 2);

            
            Assert.AreEqual(1,ii.MaxIndex());
        }
Example #3
0
        public void IsEmptyIsCorrectWhenThreeElementAndIndex2And3Removed()
        {
            HashSet <int> gaps = new HashSet <int>(new List <int> {
                2, 3
            });
            IndexIterator ii = new IndexIterator(gaps, 3);

            Assert.AreEqual(1, ii.MaxIndex());
            Assert.IsFalse(ii.IsEmpty);
        }
Example #4
0
        public void IsEmptyIsCorrectWhenTwoElementAndIndex2Removed()
        {
            var gaps = new HashSet <int>(new List <int> {
                2
            });
            var ii = new IndexIterator(gaps, 2);

            Assert.AreEqual(1, ii.MaxIndex());
            Assert.IsFalse(ii.IsEmpty);
        }
Example #5
0
        public void MaxValueIsCorrectWhenCurrentValueInGaps()
        {
            HashSet <int> gaps = new HashSet <int>(new List <int> {
                2
            });
            IndexIterator ii = new IndexIterator(gaps, 2);


            Assert.AreEqual(1, ii.MaxIndex());
        }
        public void CanIteratorNormally()
        {
            HashSet<int> gaps = new HashSet<int>();
            IndexIterator ii = new IndexIterator(gaps, 100);
            int cnt = 0;
            while (ii.HasMore())
            {
                ii.FetchNextIndex();
                cnt++;
            }

            Assert.AreEqual(cnt, 100);
        }
Example #7
0
        public void CanIteratorNormally()
        {
            HashSet <int> gaps = new HashSet <int>();
            IndexIterator ii   = new IndexIterator(gaps, 100);
            int           cnt  = 0;

            while (ii.HasMore())
            {
                ii.FetchNextIndex();
                cnt++;
            }

            Assert.AreEqual(cnt, 100);
        }
        public void CanIteratorWithGapAt1_PlusGapsEvery10()
        {
            HashSet<int> gaps = new HashSet<int>(new List<int> { 1, 11, 21, 31, 41, 51, 61, 71, 81, 91 });
            const int maxValue = 100;
            IndexIterator ii = new IndexIterator(gaps, 100);
            int cnt = 0;
            int firstIdx = -1;
            while (ii.HasMore())
            {
                int val = ii.FetchNextIndex();
                if (cnt == 0)
                {
                    firstIdx = val;
                }
                cnt++;
            }

            Assert.AreEqual(cnt, (maxValue - gaps.Count));
            Assert.AreEqual(2, firstIdx);
        }
Example #9
0
        public void CanIteratorWithGapAt1()
        {
            HashSet <int> gaps = new HashSet <int>(new List <int> {
                1
            });
            int           maxValue = 100;
            IndexIterator ii       = new IndexIterator(gaps, 100);
            int           cnt      = 0;
            int           firstIdx = -1;

            while (ii.HasMore())
            {
                int val = ii.FetchNextIndex();
                if (cnt == 0)
                {
                    firstIdx = val;
                }
                cnt++;
            }

            Assert.AreEqual(cnt, (maxValue - gaps.Count));
            Assert.AreEqual(2, firstIdx);
        }
Example #10
0
        public void CanIteratorWithGapAt1_PlusGapsEvery10()
        {
            HashSet <int> gaps = new HashSet <int>(new List <int> {
                1, 11, 21, 31, 41, 51, 61, 71, 81, 91
            });
            const int     maxValue = 100;
            IndexIterator ii       = new IndexIterator(gaps, 100);
            int           cnt      = 0;
            int           firstIdx = -1;

            while (ii.HasMore())
            {
                int val = ii.FetchNextIndex();
                if (cnt == 0)
                {
                    firstIdx = val;
                }
                cnt++;
            }

            Assert.AreEqual(cnt, maxValue - gaps.Count);
            Assert.AreEqual(2, firstIdx);
        }
        public void DistinctGetValuesWhenHasDistinctValuesShouldReturnOnlyDistinctRows()
        {
            BinaryDataListStorage bdls = new BinaryDataListStorage("MySweetNamespace", Guid.NewGuid());

            // build insert value ;)
            var row  = CreateBinaryDataListRow("1", "1", "Barney", "T", "Buchan");
            var row2 = CreateBinaryDataListRow("2", "2", "Huggs", "W", "Naidu");
            var row3 = CreateBinaryDataListRow("3", "3", "Trav", "A", "Fri");
            var row4 = CreateBinaryDataListRow("4", "4", "Trav", "B", "Fri");
            var row5 = CreateBinaryDataListRow("5", "5", "Huggs", "C", "Bear");
            var row6 = CreateBinaryDataListRow("6", "6", "Huggs", "D", "Naidu");

            bdls.Add(1, row);
            bdls.Add(2, row2);
            bdls.Add(3, row3);
            bdls.Add(4, row4);
            bdls.Add(5, row5);
            bdls.Add(6, row6);
            // Insert information

            IIndexIterator keys         = new IndexIterator(null, 6);
            List <int>     distinctCols = new List <int> {
                2, 4
            };
            List <int> rows = bdls.DistinctGetRows(keys, distinctCols);

            Assert.AreEqual(4, rows.Count);

            // now fetch each item ;)
            IBinaryDataListRow myRow;

            bdls.TryGetValue(rows[0], 1, out myRow);
            Assert.IsFalse(myRow.IsEmpty);
            bdls.TryGetValue(rows[3], 1, out myRow);
            Assert.IsFalse(myRow.IsEmpty);
        }
        public void IsEmptyIsCorrectWhenTwoElementAndIndex2Removed()
        {
            HashSet<int> gaps = new HashSet<int>(new List<int> { 2 });
            IndexIterator ii = new IndexIterator(gaps, 2);

            Assert.AreEqual(1, ii.MaxIndex());
            Assert.IsFalse(ii.IsEmpty);
        }
Example #13
0
        public async Task TestBatching()
        {
            List <ObjectToBatch> batchOne = new List <ObjectToBatch>
            {
                new ObjectToBatch {
                    ObjectID = "one", Key = "value"
                },
                new ObjectToBatch {
                    ObjectID = "two", Key = "value"
                },
                new ObjectToBatch {
                    ObjectID = "three", Key = "value"
                },
                new ObjectToBatch {
                    ObjectID = "four", Key = "value"
                },
                new ObjectToBatch {
                    ObjectID = "five", Key = "value"
                }
            };

            var batchOneResponse = await _index.SaveObjectsAsync(batchOne);

            batchOneResponse.Wait();

            List <BatchOperation <ObjectToBatch> > operations = new List <BatchOperation <ObjectToBatch> >
            {
                new BatchOperation <ObjectToBatch>
                {
                    Action = BatchActionType.AddObject, Body = new ObjectToBatch {
                        ObjectID = "zero", Key = "value"
                    }
                },
                new BatchOperation <ObjectToBatch>
                {
                    Action = BatchActionType.UpdateObject, Body = new ObjectToBatch {
                        ObjectID = "one", Key = "v"
                    }
                },
                new BatchOperation <ObjectToBatch>
                {
                    Action = BatchActionType.PartialUpdateObject, Body = new ObjectToBatch {
                        ObjectID = "two", Key = "v"
                    }
                },
                new BatchOperation <ObjectToBatch>
                {
                    Action = BatchActionType.PartialUpdateObject,
                    Body   = new ObjectToBatch {
                        ObjectID = "two_bis", Key = "value"
                    }
                },
                new BatchOperation <ObjectToBatch>
                {
                    Action = BatchActionType.PartialUpdateObjectNoCreate,
                    Body   = new ObjectToBatch {
                        ObjectID = "three", Key = "v"
                    }
                },
                new BatchOperation <ObjectToBatch>
                {
                    Action = BatchActionType.DeleteObject, Body = new ObjectToBatch {
                        ObjectID = "four"
                    }
                },
            };

            var batchTwoResponse = await _index.BatchAsync(operations);

            batchTwoResponse.Wait();

            List <ObjectToBatch>          objectsFromIterator = new List <ObjectToBatch>();
            IndexIterator <ObjectToBatch> iterator            = new IndexIterator <ObjectToBatch>(_index, new BrowseIndexQuery());

            foreach (var item in iterator)
            {
                objectsFromIterator.Add(item);
            }

            Assert.True(objectsFromIterator.Count == 6);
            Assert.True(TestHelper.AreObjectsEqual(objectsFromIterator.Find(r => r.ObjectID.Equals("zero")),
                                                   operations.Find(r => r.Body.ObjectID.Equals("zero")).Body));
            Assert.True(TestHelper.AreObjectsEqual(objectsFromIterator.Find(r => r.ObjectID.Equals("one")),
                                                   operations.Find(r => r.Body.ObjectID.Equals("one")).Body));
            Assert.True(TestHelper.AreObjectsEqual(objectsFromIterator.Find(r => r.ObjectID.Equals("two")),
                                                   operations.Find(r => r.Body.ObjectID.Equals("two")).Body));
            Assert.True(TestHelper.AreObjectsEqual(objectsFromIterator.Find(r => r.ObjectID.Equals("two_bis")),
                                                   operations.Find(r => r.Body.ObjectID.Equals("two_bis")).Body));
            Assert.True(TestHelper.AreObjectsEqual(objectsFromIterator.Find(r => r.ObjectID.Equals("three")),
                                                   operations.Find(r => r.Body.ObjectID.Equals("three")).Body));
            Assert.True(TestHelper.AreObjectsEqual(objectsFromIterator.Find(r => r.ObjectID.Equals("five")),
                                                   batchOne.Find(r => r.ObjectID.Equals("five"))));
            Assert.False(objectsFromIterator.Exists(x => x.ObjectID.Equals("four")));
        }
        //MO - Changed : new ctor that accepts the new arguments
        public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update)
        {
            errors      = new ErrorResultTO();
            ForEachType = forEachType;
            IIndexIterator localIndexIterator;

            switch (forEachType)
            {
            case enForEachType.InRecordset:

                var records = compiler.EvalRecordSetIndexes(recordsetName, update);
                if (!compiler.HasRecordSet(recordsetName))
                {
                    errors.AddError("When selecting a recordset only valid recordsets can be used");
                    break;
                }

                localIndexIterator = new IndexListIndexIterator(records);


                IndexIterator = localIndexIterator;
                break;

            case enForEachType.InRange:
                if (string.IsNullOrWhiteSpace(@from))
                {
                    errors.AddError("The from field can not be left empty.");
                    break;
                }

                if (string.IsNullOrWhiteSpace(to))
                {
                    errors.AddError("The to field can not be left empty.");
                    break;
                }

                if (@from.Contains("(*)"))
                {
                    errors.AddError("The Star notation is not accepted in the From field.");
                    break;
                }



                var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@from, update));
                int intFrom;
                if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1)
                {
                    errors.AddError("From range must be a whole number from 1 onwards.");
                    break;
                }

                if (to.Contains("(*)"))
                {
                    errors.AddError("The Star notation is not accepted in the To field.");
                    break;
                }

                var evalledTo = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@to, update));

                int intTo;
                if (!int.TryParse(evalledTo, out intTo) || intTo < 1)
                {
                    errors.AddError("To range must be a whole number from 1 onwards.");
                    break;
                }
                IndexList indexList;
                if (intFrom > intTo)
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = revIdxItr;
                }
                else
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    localIndexIterator = new IndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = localIndexIterator;
                }

                break;

            case enForEachType.InCSV:
                var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(csvNumbers, update));

                ErrorResultTO allErrors;
                List <int>    listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors);
                if (allErrors.HasErrors())
                {
                    errors.MergeErrors(allErrors);
                    break;
                }
                ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes);
                ListOfIndex       listOfIndex            = new ListOfIndex(listOfIndexes);
                listLocalIndexIterator.IndexList = listOfIndex;
                IndexIterator = listLocalIndexIterator;
                break;

            default:

                if (numberOfExecutes != null && numberOfExecutes.Contains("(*)"))
                {
                    errors.AddError("The Star notation is not accepted in the Numbers field.");
                    break;
                }

                int intExNum;
                var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(numberOfExecutes, update));

                if (!int.TryParse(numOfExItr, out intExNum))
                {
                    errors.AddError("Number of executes must be a whole number from 1 onwards.");
                }
                IndexIterator = new IndexIterator(new HashSet <int>(), intExNum);
                break;
            }
        }
        //MO - Changed : new ctor that accepts the new arguments
        public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update)
        {
            errors      = new ErrorResultTO();
            ForEachType = forEachType;
            IIndexIterator localIndexIterator;

            switch (forEachType)
            {
            case enForEachType.InRecordset:

                if (string.IsNullOrEmpty(recordsetName))
                {
                    errors.AddError(string.Format(ErrorResource.IsRequired, "The Recordset Field"));
                    break;
                }
                var records = compiler.EvalRecordSetIndexes(recordsetName, update);
                if (!compiler.HasRecordSet(recordsetName))
                {
                    errors.AddError("When selecting a recordset only valid recordsets can be used");
                    break;
                }

                localIndexIterator = new IndexListIndexIterator(records);


                IndexIterator = localIndexIterator;
                break;

            case enForEachType.InRange:
                if (string.IsNullOrWhiteSpace(@from))
                {
                    errors.AddError(string.Format(ErrorResource.IsRequired, "The FROM field"));
                    break;
                }

                if (string.IsNullOrWhiteSpace(to))
                {
                    errors.AddError(string.Format(ErrorResource.IsRequired, "The TO field"));
                    break;
                }

                if (@from.Contains("(*)"))
                {
                    errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "From field"));
                    break;
                }



                var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@from, update));
                int intFrom;
                if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1)
                {
                    errors.AddError(string.Format(ErrorResource.RangeFromOne, "FROM range"));
                    break;
                }

                if (to.Contains("(*)"))
                {
                    errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "TO field."));
                    break;
                }

                var evalledTo = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(@to, update));

                int intTo;
                if (!int.TryParse(evalledTo, out intTo) || intTo < 1)
                {
                    errors.AddError(string.Format(ErrorResource.RangeFromOne, "TO range"));
                    break;
                }
                IndexList indexList;
                if (intFrom > intTo)
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    var revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = revIdxItr;
                }
                else
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    localIndexIterator = new IndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = localIndexIterator;
                }

                break;

            case enForEachType.InCSV:
                if (string.IsNullOrEmpty(csvNumbers))
                {
                    errors.AddError(string.Format(ErrorResource.IsRequired, "The CSV Field"));
                    break;
                }
                var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(csvNumbers, update));

                ErrorResultTO allErrors;
                var           listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors);
                if (allErrors.HasErrors())
                {
                    errors.MergeErrors(allErrors);
                    break;
                }
                var listLocalIndexIterator = new ListIndexIterator(listOfIndexes);
                var listOfIndex            = new ListOfIndex(listOfIndexes);
                listLocalIndexIterator.IndexList = listOfIndex;
                IndexIterator = listLocalIndexIterator;
                break;

            default:

                if (numberOfExecutes != null && numberOfExecutes.Contains("(*)"))
                {
                    errors.AddError(string.Format(ErrorResource.StarNotationNotAllowed, "Numbers field."));
                    break;
                }

                int intExNum;
                var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString(compiler.Eval(numberOfExecutes, update));

                if (!int.TryParse(numOfExItr, out intExNum) || intExNum < 1)
                {
                    errors.AddError(string.Format(ErrorResource.RangeFromOne, "Number of executes"));
                }
                IndexIterator = new IndexIterator(new HashSet <int>(), intExNum);
                break;
            }
        }
Example #16
0
        //MO - Changed : new ctor that accepts the new arguments
        public ForEachBootstrapTOOld(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, Guid dlID, IDataListCompiler compiler, out ErrorResultTO errors)
        {
            errors      = new ErrorResultTO();
            ForEachType = forEachType;
            IDev2IteratorCollection colItr = Dev2ValueObjectFactory.CreateIteratorCollection();
            IndexIterator           localIndexIterator;
            IndexList indexList;

            switch (forEachType)
            {
            case enForEachType.InRecordset:
                IBinaryDataListEntry recordset = compiler.Evaluate(dlID, enActionType.User, recordsetName, false, out errors);

                if (recordset == null || !recordset.IsRecordset)
                {
                    errors.AddError("When selecting a recordset only valid recordsets can be used");
                    break;
                }


                var isEmpty = recordset.IsEmpty();
                if (isEmpty)
                {
                    indexList = new IndexList(new HashSet <int> {
                        1
                    }, 0);
                    localIndexIterator = new IndexIterator(new HashSet <int> {
                        1
                    }, 0);
                }
                else
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = 1, MaxValue = recordset.FetchLastRecordsetIndex()
                    };
                    localIndexIterator = new IndexIterator(new HashSet <int>(), 0);
                }

                localIndexIterator.IndexList = indexList;
                IndexIterator = localIndexIterator;
                break;

            case enForEachType.InRange:
                if (string.IsNullOrWhiteSpace(from))
                {
                    errors.AddError("The from field can not be left empty.");
                    break;
                }

                if (string.IsNullOrWhiteSpace(to))
                {
                    errors.AddError("The to field can not be left empty.");
                    break;
                }

                if (from.Contains("(*)"))
                {
                    errors.AddError("The Star notation is not accepted in the From field.");
                    break;
                }

                var fromItr = CreateDataListEvaluateIterator(from, dlID, compiler, colItr, errors);
                colItr.AddIterator(fromItr);

                int intFrom;
                if (!int.TryParse(colItr.FetchNextRow(fromItr).TheValue, out intFrom) || intFrom < 1)
                {
                    errors.AddError("From range must be a whole number from 1 onwards.");
                    break;
                }

                if (to.Contains("(*)"))
                {
                    errors.AddError("The Star notation is not accepted in the To field.");
                    break;
                }

                var toItr = CreateDataListEvaluateIterator(to, dlID, compiler, colItr, errors);
                colItr.AddIterator(toItr);

                int intTo;
                if (!int.TryParse(colItr.FetchNextRow(toItr).TheValue, out intTo) || intTo < 1)
                {
                    errors.AddError("To range must be a whole number from 1 onwards.");
                    break;
                }
                if (intFrom > intTo)
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = revIdxItr;
                }
                else
                {
                    indexList = new IndexList(new HashSet <int>(), 0)
                    {
                        MinValue = intFrom, MaxValue = intTo
                    };
                    localIndexIterator = new IndexIterator(new HashSet <int>(), 0)
                    {
                        IndexList = indexList
                    };
                    IndexIterator = localIndexIterator;
                }

                break;

            case enForEachType.InCSV:
                var csvIndexedsItr = CreateDataListEvaluateIterator(csvNumbers, dlID, compiler, colItr, errors);
                colItr.AddIterator(csvIndexedsItr);
                ErrorResultTO allErrors;
                List <int>    listOfIndexes = SplitOutCsvIndexes(colItr.FetchNextRow(csvIndexedsItr).TheValue, out allErrors);
                if (allErrors.HasErrors())
                {
                    errors.MergeErrors(allErrors);
                    break;
                }
                ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes);
                ListOfIndex       listOfIndex            = new ListOfIndex(listOfIndexes);
                listLocalIndexIterator.IndexList = listOfIndex;
                IndexIterator = listLocalIndexIterator;
                break;

            default:

                if (numberOfExecutes != null && numberOfExecutes.Contains("(*)"))
                {
                    errors.AddError("The Star notation is not accepted in the Numbers field.");
                    break;
                }

                int intExNum;
                var numOfExItr = CreateDataListEvaluateIterator(numberOfExecutes, dlID, compiler, colItr, errors);
                colItr.AddIterator(numOfExItr);

                if (!int.TryParse(colItr.FetchNextRow(numOfExItr).TheValue, out intExNum))
                {
                    errors.AddError("Number of executes must be a whole number from 1 onwards.");
                }
                IndexIterator = new IndexIterator(new HashSet <int>(), intExNum);
                break;
            }
        }
Example #17
0
        /// <inheritdoc />
        public async Task <MultiResponse> CopyIndexAsync <T>(ISearchIndex sourceIndex, ISearchIndex destinationIndex,
                                                             RequestOptions requestOptions = null, CancellationToken ct = default) where T : class
        {
            if (sourceIndex.Config.AppId.Equals(destinationIndex.Config.AppId))
            {
                throw new AlgoliaException("Source and Destination indices should not be on the same application.");
            }

            // TODO: improve this section
            try
            {
                IndexSettings destinationSettings =
                    await destinationIndex.GetSettingsAsync(ct : ct).ConfigureAwait(false);

                if (destinationSettings != null)
                {
                    throw new AlgoliaException(
                              "Destination index already exists. Please delete it before copying index across applications.");
                }
            }
            catch (AlgoliaApiException ex)
            {
                // We want to catch an non existing index exception (404) and continue
                // Otherwise, we want to throw if it's another Http exception
                if (ex.HttpErrorCode != 404)
                {
                    throw;
                }
            }

            MultiResponse ret = new MultiResponse {
                Responses = new List <IAlgoliaWaitableResponse>()
            };

            // Save settings
            IndexSettings sourceSettings = await sourceIndex.GetSettingsAsync(ct : ct).ConfigureAwait(false);

            SetSettingsResponse destinationSettingsResp = await destinationIndex
                                                          .SetSettingsAsync(sourceSettings, requestOptions, ct)
                                                          .ConfigureAwait(false);

            ret.Responses.Add(destinationSettingsResp);

            // Save synonyms
            SynonymsIterator    sourceSynonyms             = new SynonymsIterator(sourceIndex);
            SaveSynonymResponse destinationSynonymResponse = await destinationIndex
                                                             .SaveSynonymsAsync(sourceSynonyms, requestOptions : requestOptions, ct : ct)
                                                             .ConfigureAwait(false);

            ret.Responses.Add(destinationSynonymResponse);

            // Save rules
            RulesIterator sourceRules             = new RulesIterator(sourceIndex);
            BatchResponse destinationRuleResponse = await destinationIndex
                                                    .SaveRulesAsync(sourceRules, requestOptions : requestOptions, ct : ct)
                                                    .ConfigureAwait(false);

            ret.Responses.Add(destinationRuleResponse);

            // Save objects (batched)
            IndexIterator <T>     indexIterator = sourceIndex.Browse <T>(new BrowseIndexQuery());
            BatchIndexingResponse saveObject    = await destinationIndex
                                                  .SaveObjectsAsync(indexIterator, requestOptions, ct)
                                                  .ConfigureAwait(false);

            ret.Responses.Add(saveObject);

            return(ret);
        }
        //MO - Changed : new ctor that accepts the new arguments
        public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update)
        {
            errors = new ErrorResultTO();
            ForEachType = forEachType;
            IIndexIterator localIndexIterator;

            switch(forEachType)
            {
                case enForEachType.InRecordset:
                    
                    var records = compiler.EvalRecordSetIndexes(recordsetName, update);
                    if (!compiler.HasRecordSet(recordsetName) )
                    {
                        errors.AddError("When selecting a recordset only valid recordsets can be used");
                        break;
                    }

                        localIndexIterator = new IndexListIndexIterator(records);

                    
                    IndexIterator = localIndexIterator;
                    break;

                case enForEachType.InRange:
                    if(string.IsNullOrWhiteSpace(@from))
                    {
                        errors.AddError("The from field can not be left empty.");
                        break;
                    }

                    if(string.IsNullOrWhiteSpace(to))
                    {
                        errors.AddError("The to field can not be left empty.");
                        break;
                    }

                    if(@from.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the From field.");
                        break;
                    }

                    

                    var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@from, update));
                    int intFrom;
                    if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1)
                    {
                        errors.AddError("From range must be a whole number from 1 onwards.");
                        break;
                    }

                    if(to.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the To field.");
                        break;
                    }

                    var evalledTo= ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@to, update));
               
                    int intTo;
                    if (!int.TryParse(evalledTo, out intTo) || intTo < 1)
                    {
                        errors.AddError("To range must be a whole number from 1 onwards.");
                        break;
                    }
                    IndexList indexList;
                    if(intFrom > intTo)
                    {
                        indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo };
                        ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet<int>(), 0) { IndexList = indexList };
                        IndexIterator = revIdxItr;
                    }
                    else
                    {
                        indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo };
                        localIndexIterator = new IndexIterator(new HashSet<int>(), 0) { IndexList = indexList };
                        IndexIterator = localIndexIterator;
                    }

                    break;
                case enForEachType.InCSV:
                    var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(csvNumbers, update));

                    ErrorResultTO allErrors;
                    List<int> listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors);
                    if(allErrors.HasErrors())
                    {
                        errors.MergeErrors(allErrors);
                        break;
                    }
                    ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes);
                    ListOfIndex listOfIndex = new ListOfIndex(listOfIndexes);
                    listLocalIndexIterator.IndexList = listOfIndex;
                    IndexIterator = listLocalIndexIterator;
                    break;
                default:

                    if(numberOfExecutes != null && numberOfExecutes.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the Numbers field.");
                        break;
                    }

                    int intExNum;
                    var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(numberOfExecutes, update));

                    if (!int.TryParse(numOfExItr, out intExNum))
                    {
                        errors.AddError("Number of executes must be a whole number from 1 onwards.");
                    }
                    IndexIterator = new IndexIterator(new HashSet<int>(), intExNum);
                    break;
            }

        }