protected override IIndexCriteria GetIndexerData(IndexSet indexSet) { // examine fields var data = base.GetIndexerData(indexSet); // azure config var path = System.Web.Hosting.HostingEnvironment.MapPath("~/"); var serviceClient = new AzureSearchIndexClient(path); var examineStandardFields = data.StandardFields; var examineUserFields = data.UserFields; var azureStandardFields = serviceClient.GetStandardUmbracoFields().ToDictionary(f => f.Name); var azureUserFields = serviceClient.GetConfiguration().SearchFields.ToDictionary(f => f.Name); var standardToRemove = examineStandardFields.Where(examineField => !azureStandardFields.Keys.InvariantContains(examineField.Name)); var validStandardFields = examineStandardFields.Except(standardToRemove); var userToRemove = examineUserFields.Where(examineField => !azureUserFields.Keys.InvariantContains(examineField.Name)); var validUserFields = examineUserFields.Except(userToRemove); var newData = new IndexCriteria(validStandardFields, validUserFields, data.IncludeNodeTypes, data.ExcludeNodeTypes, data.ParentNodeId); return(newData); }
protected override string[] GetSearchFields() { var path = System.Web.Hosting.HostingEnvironment.MapPath("~/"); var serviceClient = new AzureSearchIndexClient(path); var systemFields = serviceClient.GetStandardUmbracoFields().Where(f => f.IsSearchable).Select(f => f.Name); var configFields = serviceClient.GetConfiguration().SearchFields.Where(f => f.IsSearchable).Select(f => f.Name); return(systemFields.Concat(configFields).ToArray()); }