public Indexer CreateTestIndexerWithSkillset(string skillsetName, IList <FieldMapping> outputFieldMapping) { return(new Indexer(name: SearchTestUtilities.GenerateName(), dataSourceName: DataSourceName, targetIndexName: TargetIndexName, skillsetName: skillsetName) { // 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)), OutputFieldMappings = outputFieldMapping }); }
public override void Initialize(MockContext context) { base.Initialize(context); SearchServiceClient searchClient = this.GetSearchServiceClient(); TargetIndexName = SearchTestUtilities.GenerateName(); DataSourceName = SearchTestUtilities.GenerateName(); var index = new Index( TargetIndexName, new[] { new Field("feature_id", DataType.String) { IsKey = true }, new Field("feature_name", DataType.String) { IsFilterable = true, IsSearchable = true }, new Field("feature_class", DataType.String), new Field("state", DataType.String) { IsFilterable = true, IsSearchable = true }, new Field("county_name", DataType.String) { IsFilterable = true, IsSearchable = true }, new Field("elevation", DataType.Int32) { IsFilterable = true }, new Field("map_name", DataType.String) { IsFilterable = true, IsSearchable = true }, new Field("history", DataType.Collection(DataType.String)) { IsSearchable = true } }); searchClient.Indexes.Create(index); var dataSource = DataSource.AzureSql( name: DataSourceName, sqlConnectionString: AzureSqlReadOnlyConnectionString, tableOrViewName: AzureSqlTestTableName); searchClient.DataSources.Create(dataSource); }
public override void Initialize(MockContext context) { base.Initialize(context); SearchServiceClient searchClient = this.GetSearchServiceClient(); IndexName = SearchTestUtilities.GenerateName(); var index = CreateTestIndex(IndexName); searchClient.Indexes.Create(index); // Give the index time to stabilize before running tests. // TODO: Remove this workaround once the retry hang bug is fixed. TestUtilities.Wait(TimeSpan.FromSeconds(20)); }
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"), new FieldMapping("county_name", FieldMappingFunction.ExtractTokenAtPosition(" ", 0)), new FieldMapping("elev_in_m", "elevation"), new FieldMapping("map_name", FieldMappingFunction.Base64Decode()), new FieldMapping("history", FieldMappingFunction.JsonArrayToStringCollection()) } };
public virtual void Initialize(MockContext context) { ResourceManagementClient client = context.GetServiceClient <ResourceManagementClient>(); // Register subscription and get a valid location for search services. Provider provider = client.Providers.Register(SearchNamespace); Assert.NotNull(provider); // We only support one resource type. Location = provider.ResourceTypes.First().Locations.First(); // Create resource group ResourceGroupName = SearchTestUtilities.GenerateName(); ResourceGroup resourceGroup = client.ResourceGroups.CreateOrUpdate(ResourceGroupName, new ResourceGroup() { Location = Location }); Assert.NotNull(resourceGroup); }
public override void Initialize(MockContext context) { base.Initialize(context); SearchServiceClient searchClient = this.GetSearchServiceClient(); IndexName = SearchTestUtilities.GenerateName(); // This is intentionally a different index definition than the one returned by IndexTests.CreateTestIndex(). // That index is meant to exercise serialization of the index definition itself, while this one is tuned // more for exercising document serialization, indexing, and querying operations. var index = new Index() { Name = IndexName, Fields = new[] { new Field("hotelId", DataType.String) { IsKey = true, IsFilterable = true, IsSortable = true, IsFacetable = true }, new Field("baseRate", DataType.Double) { IsFilterable = true, IsSortable = true, IsFacetable = true }, new Field("description", DataType.String) { IsSearchable = true }, new Field("descriptionFr", AnalyzerName.FrLucene), new Field("hotelName", DataType.String) { IsSearchable = true, IsFilterable = true, IsSortable = true, IsFacetable = true }, new Field("category", DataType.String) { IsSearchable = true, IsFilterable = true, IsSortable = true, IsFacetable = true }, new Field("tags", DataType.Collection(DataType.String)) { IsSearchable = true, IsFilterable = true, IsFacetable = true }, new Field("parkingIncluded", DataType.Boolean) { IsFilterable = true, IsSortable = true, IsFacetable = true }, new Field("smokingAllowed", DataType.Boolean) { IsFilterable = true, IsSortable = true, IsFacetable = true }, new Field("lastRenovationDate", DataType.DateTimeOffset) { IsFilterable = true, IsSortable = true, IsFacetable = true }, new Field("rating", DataType.Int32) { IsFilterable = true, IsSortable = true, IsFacetable = true }, new Field("location", DataType.GeographyPoint) { IsFilterable = true, IsSortable = true } }, Suggesters = new[] { new Suggester( name: "sg", searchMode: SuggesterSearchMode.AnalyzingInfixMatching, sourceFields: new[] { "description", "hotelName" }) }, ScoringProfiles = new[] { new ScoringProfile("nearest") { FunctionAggregation = ScoringFunctionAggregation.Sum, Functions = new[] { new DistanceScoringFunction("location", 2, new DistanceScoringParameters("myloc", 100)) } } } }; searchClient.Indexes.Create(index); // Give the index time to stabilize before running tests. // TODO: Remove this workaround once the retry hang bug is fixed. TestUtilities.Wait(TimeSpan.FromSeconds(20)); }