I have a custom ISearchableContentType
I'm wondering once I create new content of that type, how long will it take before it shows up in the search index?
I have a custom ISearchableContentType
I'm wondering once I create new content of that type, how long will it take before it shows up in the search index?
Ok...interesting...the results show up if I am anonymous, so it appears I might need to add more roles?
I got it working... Had to add all roles as separate index fields. Seems like the GetViewSecurityRoles(Guid contentId) call never executed to add role ids to the search document.
public IList<SearchIndexDocument> GetContentToIndex()
{
List<SearchIndexDocument> documents = new List<SearchIndexDocument>();
var pages = Components.CMSPages.ListPages();
foreach (var page in pages)
{
if (page.IsPublished)
{
List<IndexField> fields = new List<IndexField>();
fields.Add(new IndexField("collapse",String.Format("{0}:{1}","WebContent",page.ContentId)));
fields.Add(new IndexField("roles", "1"));
fields.Add(new IndexField("roles", "3"));
fields.Add(new IndexField("roles", "4"));
var doc = Apis.Get<ISearchIndexing>().NewDocument(page.ContentId, Components.CMSPages.CMS_PAGE_CONTENT_TYPE_ID, "WebContent", page.Url, page.MetaTitle, page.ContentBlob);
doc.Id = page.ContentId.ToString();
doc.ContentTypeId = Components.CMSPages.CMS_PAGE_CONTENT_TYPE_ID;
doc.IndexFields = fields;
doc.Title = page.MetaTitle;
doc.Content = page.ContentBlob;
doc.Id = page.ContentId.ToString();
doc.TypeName = "WebContent";
doc.Url = page.Url;
doc.ContentTypeId = Components.CMSPages.CMS_PAGE_CONTENT_TYPE_ID;
documents.Add(doc);
}
}
return documents;
}
public string GetViewHtml(IContent content, Target target)
{
var page = Components.CMSPages.Get(content.ContentId);
return page.MetaDescription;
}
public int[] GetViewSecurityRoles(Guid contentId)
{
List<int> roleIds = new List<int>();
// Add the Everyone Role
roleIds.Add(1);
roleIds.Add(3);
roleIds.Add(4);
roleIds.Add(2);
return roleIds.ToArray();
}