public void Get_All_User_Property_Names() { var contentService = new UmbracoContentService(ApplicationContext); var db = DatabaseContext.Database; var result = contentService.GetAllUserPropertyNames(); Assert.IsTrue(result.Select(x => x).ContainsAll(new[] { "contents", Constants.Conventions.Media.Bytes, Constants.Conventions.Media.Extension, Constants.Conventions.Media.File, Constants.Conventions.Media.Height, Constants.Conventions.Media.Width })); }
public Field[] GetStandardUmbracoFields() { var cachedFields = ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem("AzureSearch_UmbracoFields", () => { var fields = new List <Field> { // Key field has to be a string.... new Field("Id", DataType.String) { IsKey = true, IsFilterable = true, IsSortable = true }, new Field("Name", DataType.String) { IsFilterable = true, IsSortable = true, IsSearchable = true, IsRetrievable = true }, new Field("Key", DataType.String) { IsSearchable = true, IsRetrievable = true }, new Field("Url", DataType.String) { IsSearchable = true, IsRetrievable = true }, new Field("MemberEmail", DataType.String) { IsSearchable = true }, new Field("IsContent", DataType.Boolean) { IsFilterable = true, IsFacetable = true }, new Field("IsMedia", DataType.Boolean) { IsFilterable = true, IsFacetable = true }, new Field("IsMember", DataType.Boolean) { IsFilterable = true, IsFacetable = true }, new Field("Published", DataType.Boolean) { IsFilterable = true, IsFacetable = true }, new Field("Trashed", DataType.Boolean) { IsFilterable = true, IsFacetable = true }, new Field("SearchablePath", DataType.String) { IsSearchable = true, IsFilterable = true }, new Field("Path", DataType.Collection(DataType.String)) { IsSearchable = true, IsFilterable = true }, new Field("Template", DataType.String) { IsSearchable = true, IsFacetable = true }, new Field("Icon", DataType.String) { IsSearchable = true, IsFacetable = true }, new Field("ContentTypeAlias", DataType.String) { IsSearchable = true, IsFacetable = true, IsFilterable = true }, new Field("UpdateDate", DataType.DateTimeOffset) { IsFilterable = true, IsSortable = true }, new Field("CreateDate", DataType.DateTimeOffset) { IsFilterable = true, IsSortable = true }, new Field("ContentTypeId", DataType.Int32) { IsFilterable = true }, new Field("ParentID", DataType.String) { IsFilterable = true, IsSearchable = true }, new Field("Level", DataType.Int32) { IsSortable = true, IsFacetable = true }, new Field("SortOrder", DataType.Int32) { IsSortable = true }, new Field("WriterId", DataType.Int32) { IsSortable = true, IsFacetable = true }, new Field("CreatorId", DataType.Int32) { IsSortable = true, IsFacetable = true }, new Field("WriterName", DataType.String) { IsSortable = true, IsFacetable = true }, new Field("CreatorName", DataType.String) { IsSortable = true, IsFacetable = true } }; var examineContentService = new UmbracoContentService(ApplicationContext.Current); var existingNames = fields.Select(f => f.Name); // get system properties which haven't already been defined above foreach (var name in examineContentService.GetAllSystemPropertyNames().Where(fn => !existingNames.InvariantContains(fn))) { fields.Add(new Field { Name = name, Type = DataType.String, IsFilterable = true, IsSearchable = true, // Treats the entire content of a field as a single token Analyzer = AnalyzerName.Keyword }); } // get 'system' fields like umbracoWidth, umbracoBytes, umbracoNaviHide etc var umbracoFields = examineContentService.GetAllUserPropertyNames().Where(f => f.StartsWith("umbraco")); foreach (var name in umbracoFields) { fields.Add(new Field { Name = name, Type = DataType.String, IsFilterable = true, IsSearchable = true, // Treats the entire content of a field as a single token Analyzer = AnalyzerName.Keyword }); } // sort, but ensure key is always first var keyField = fields.FirstOrDefault(f => f.IsKey); var sorted = fields.Except(new [] { keyField }).OrderBy(f => f.Name).ToList(); sorted.Insert(0, keyField); return(sorted.ToArray()); }, TimeSpan.FromMinutes(5)) as Field[]; return(cachedFields); }