Search results for custom content not present - ISearchableContentType

Hi,

I trying to implement SearchableContentType from custom application.
created ISearchableContentType plugin and added the .dll in to the Job folder.
Search box return the results of comments only (from custom application) because that is stored in default table (te_Comment_Comments)
but it also have the content like company and product these data are stored in the custom table with IsIndex column.
Data in the custom table are not get indexed. So, it is not listing in the search list. What else I am missing to get the custom search results from custom table

Parents Reply Children
  • It's not hitting GetContentToIndex(), I implemented ISearchableContentType interface in both my ContentType class and Application Type class exactly same as the below. Could you please to guide us to make it work?

  • Is ISearchableContentType listed as one of the interfaces in that class?  Is the ContentType enabled on your site?


  • Yes Mathew, It's custom application with core functionalities like (bookmark, comment, tag, like), everything works fine expect the search functionality.

  • Also when you resolve the issue with it not triggering, you don't appear to be adding the custom fields to the doc passed to solr ? 

    e.g.
    doc.AddField('ext_Product" , link.Product);


  • Here I implemented ISearchableContentType as an interface in my application. I also try to reindex my search. nothing seems to be working. How to add custom fields to the doc passed to solr?

    #region ISearchableContentType
    
            public void SetIndexStatus(Guid[] contentIds, bool isIndexed)
            {
                LinksData.UpdateStatus(contentIds, isIndexed);
            }
    
            public IList<SearchIndexDocument> GetContentToIndex()
            {
                var docs = new List<SearchIndexDocument>();
               
                var links = MarketplaceInformation.GetAllCompany().Where(link => !link.IsIndexed);
    
                foreach (var link in links)
                {
                    if (link == null) { continue; }
    
                    var doc = Apis.Get<ISearchIndexing>().NewDocument(new Guid(link.ContentId), link.ContentTypeId, "linkitem", link.Url, link.HtmlName("web"), link.HtmlDescription("web"));
                    doc.AddField("date", Apis.Get<ISearchIndexing>().FormatDate(link.CreatedDate));
                    docs.Add(doc);
                }
    
                return docs;
            }
    
            public int[] GetViewSecurityRoles(Guid contentId)      
            {
                var content = MarketplaceInformation.GetCompany(contentId.ToString());
                if (content == null) { return new int[] { }; }
                if (content.Application == null) { return new int[] { }; }
    
                var Roles = Apis.Get<IRoles>().Find("Registered Users");
                //var iRoles = Roles.Select(r => r.Id.GetValueOrDefault()).ToArray();
    
                //return Apis.Get<IRoles>().Find("Registered Users").Select(r => r.Id.GetValueOrDefault()).ToArray();
                return new int[0];
            }
    
            string ISearchableContentType.GetViewHtml(IContent content, Target target)
            {
                if (content == null) { return null; }
    
                var user = Apis.Get<IUsers>().Get(new UsersGetOptions { Id = content.CreatedByUserId });
    
                var author = String.Format(@"<a href=""{0}"" class=""internal-link view-user-profile""><span></span>{1}</a>", PublicApi.Html.EncodeAttribute(user.ProfileUrl), PublicApi.Html.Encode(user.DisplayName));
    
                var appLink = content.Application != null
                    ? String.Format(@"<a href=""{0}"">{1}</a>", PublicApi.Html.EncodeAttribute(content.Application.Url), content.Application.HtmlName(target.ToString()))
                    : String.Empty;
    
                var groupLink = content.Application != null && content.Application.Container != null
                    ? String.Format(@"<a href=""{0}"">{1}</a>", PublicApi.Html.EncodeAttribute(content.Application.Container.Url), content.Application.Container.HtmlName(target.ToString()))
                    : String.Empty;
    
                return String.Format(@"
    <div class=""abbreviated-post-header""></div>
    <div class=""abbreviated-post ui-searchresult"">
        <div class=""post-metadata"">
            <ul class=""property-list"">
                <li class=""property-item date"">{0}</li>
                    <li class=""property-item author"">
                        <span class=""user-name"">{1}</span>
                    </li>
                <li>
                    <ul class=""details"">
                        <li class=""property-item type""></li>
                    </ul>
                </li>
            </ul>
        </div>
        <h4 class=""post-name"">
            <a class=""internal-link view-post"" title=""{3}"" href=""{4}"">
                {2}
            </a>
        </h4>
        <div class=""post-summary"">{5}</div>
        <div class=""post-application"">
            {6}
            {7}
        </div>
    </div>
    <div class=""abbreviated-post-footer""></div>",
                Apis.Get<ILanguage>().FormatDate(content.CreatedDate),
                author,
                content.HtmlName("web"),
                content.HtmlName("web"),
                PublicApi.Html.EncodeAttribute(content.Url),
                content.HtmlDescription("web"),
                appLink,
                groupLink);
            }
            #endregion

  • You can also check in Administration under Site > Search on the Include tab and make sure your custom content type is not disabled.

  •  Administration under Site > Search under include my custom content type is enabled.