Esempio n. 1
0
        public void CanRoundtripIndexerWithFieldMappingFunctions() =>
        Run(() =>
        {
            Indexer expectedIndexer = new Indexer(SearchTestUtilities.GenerateName(), Data.DataSourceName, Data.TargetIndexName)
            {
                FieldMappings = new[]
                {
                    // Try all the field mapping functions and parameters (even if they don't make sense in the context of the test DB).
                    new FieldMapping("feature_id", "a", FieldMappingFunction.Base64Encode()),
                    new FieldMapping("feature_id", "b", FieldMappingFunction.Base64Encode(useHttpServerUtilityUrlTokenEncode: true)),
                    new FieldMapping("feature_id", "c", FieldMappingFunction.ExtractTokenAtPosition(delimiter: " ", position: 0)),
                    new FieldMapping("feature_id", "d", FieldMappingFunction.Base64Decode()),
                    new FieldMapping("feature_id", "e", FieldMappingFunction.Base64Decode(useHttpServerUtilityUrlTokenDecode: false)),
                    new FieldMapping("feature_id", "f", FieldMappingFunction.JsonArrayToStringCollection()),
                    new FieldMapping("feature_id", "g", FieldMappingFunction.UrlEncode()),
                    new FieldMapping("feature_id", "h", FieldMappingFunction.UrlDecode()),
                }
            };

            SearchServiceClient searchClient = Data.GetSearchServiceClient();

            // We need to add desired fields to the index before those fields can be referenced by the field mappings
            Index index         = searchClient.Indexes.Get(Data.TargetIndexName);
            string[] fieldNames = new[] { "a", "b", "c", "d", "e", "f", "g", "h" };
            index.Fields        = index.Fields.Concat(fieldNames.Select(name => new Field(name, DataType.String))).ToList();
            searchClient.Indexes.CreateOrUpdate(index);

            searchClient.Indexers.Create(expectedIndexer);

            Indexer actualIndexer = searchClient.Indexers.Get(expectedIndexer.Name);
            AssertIndexersEqual(expectedIndexer, actualIndexer);
        });
Esempio n. 2
0
 public Indexer CreateTestIndexer() =>
 new Indexer(SearchTestUtilities.GenerateName(), DataSourceName, TargetIndexName)
 {
     // We can't test startTime because it's an absolute time that must be within 24 hours of the current
     // time. That doesn't play well with recorded mock payloads.
     Schedule      = new IndexingSchedule(interval: TimeSpan.FromDays(1)),
     FieldMappings = new[]
     {
         // Try all the field mapping functions (even if they don't make sense in the context of the test DB).
         new FieldMapping("feature_class", FieldMappingFunction.Base64Encode()),
         new FieldMapping("state_alpha", "state", FieldMappingFunction.UrlEncode()),
         new FieldMapping("county_name", FieldMappingFunction.ExtractTokenAtPosition(" ", 0)),
         new FieldMapping("elev_in_m", "elevation", FieldMappingFunction.UrlDecode()),
         new FieldMapping("map_name", FieldMappingFunction.Base64Decode()),
         new FieldMapping("history", FieldMappingFunction.JsonArrayToStringCollection())
     }
 };