Trying to add custom content to search

Hello,

I am trying to make some content from an API available in Telligent's search results. So I followed the documentation here community.telligent.com/.../search and I implemented and released locally. I have the Job scheduler running, but my content is not available via Search. 
More specifically I can't see the GetContentToIndex being called at all. Has any of you managed to implement it this ISearchableContentType interface and find the results in Search?

Thank you for your response

  • Is your plugin enabled?

    is the DLL containing the plugin present in both the web bin folder and job scheduler folder?

    Any exceptions in the log that may be related?

    Can you post your code so we can review it?

  • Hi Mathew,

    thank you for your really quick reply. So you are right. I didn't know that the dll should also go into the job scheduler folder. I have added it there and I can see the search results through solr (ex http://localhost:8983/solr/telligent-content/select?q=Seat), but not on the search through the Telligent community. 
    The plug in is enabled, and I don't see any exceptions :)

  • can i see the code for your ISearchableContentType implementation?

  • Hi Mathew,  I have included the code.

    #region ISearchableContentType
    	public bool IsCacheable => true;
    
    	public bool VaryCacheByUser => true;
    	
    	public void SetIndexStatus(Guid[] contentIds, bool isIndexed)
    	{
    		
    	}
    
    	public IList<SearchIndexDocument> GetContentToIndex()
    	{
    		var docs = new List<SearchIndexDocument>();
    		var assets = AssetData.GetAssets();
    		foreach (var asset in assets)
    		{
    			if (asset == null) { continue; }
    			var searchDocument = Apis.Get<ISearchIndexing>().NewDocument(asset.ContentId, asset.ContentTypeId, "Material", asset.Url, asset.Name, asset.HtmlDescription(asset.Description));
    			docs.Add(searchDocument);
    		}
    
    		return docs;
    	}
    
    	public int[] GetViewSecurityRoles(Guid contentId)
    	{
    		var roles = Apis.Get<IRoles>().Find("Everyone").Select(r => r.Id.GetValueOrDefault()).ToArray();
    		return roles;
    	}
    
    	public string GetViewHtml(IContent content, Target target)
    	{
    		if (content == null) { return null; }
    		return string.Format("FOUND ITEM " + content.Url);
    	}
    #endregion

  • Hi Mathew.

    do you happen to understand what is happening there. To more accurate when I make a query through SOLR I can see this document. My community will display the new Category called "Material", but I will not find any items in Search. 

    <doc>
    <str name="id">cd247598-f451-422f-9e9a-6d959802800a</str>
    <str name="contenttypeid">ce4524e1-a88d-4904-98e9-4ec5575926d2</str>
    <str name="type">Material</str>
    <str name="url">
    https://a-url.com
    </str>
    <str name="title">1026 session.mp4</str>
    <str name="titlesort">1026 session.mp4</str>
    <str name="content">mycontent</str>
    <str name="rawcontent">mycontent</str>
    <arr name="roles">
    <str>4</str>
    <str>1</str>
    <str>3</str>
    <str>2</str>
    <str>26</str>
    </arr>
    <date name="date">2017-10-26T14:40:00Z</date>
    <double name="contentscore">0.0285714285714286</double>
    <arr name="category">
    <str>Material</str>
    </arr>
    <bool name="iscontent">false</bool>
    <date name="indexed_at">2017-11-29T15:16:33.061Z</date>
    <str name="dummy_id">1</str>
    <bool name="isapplication">false</bool>
    <bool name="iscontainer">false</bool>
    <long name="_version_">1585413979438579712</long>
    <float name="score">3.4029944</float>
    </doc>
    

  • Can you confirm that GetViewSecurityRoles is returning the correct id(s) in the array?

  • Hi Steven,

    I tried to return from GetViewSecurityRoles  both Apis.Get<IRoles>().List().Select(r => r.Id.GetValueOrDefault()).ToArray(); (ids = 1,2,3,4,26)

    and 
    Apis.Get<IRoles>().Find("Everyone").Select(r => r.Id.GetValueOrDefault()).ToArray();

  • We found that this is because the collapse field is required to be added to the indexed content.

    The problem arises because, when using Fiddler to inspect the search request the platform makes to Solr, I noticed that one of the fq parameters was {!collapse field=collapse}. This requires the results to be collapsed, based on the value in the ‘collapse’ field. However, as you are not setting this, it’s excluded from results. Luckily, the fix should be simple. If you add the line highlighted below to your code, once the content is indexed again it should start to show up in results as expected.

     

                foreach (var asset in assets)

                {

                    if (asset == null) { continue; }

                                   searchDocument.AddField(Apis.Get<SearchIndexing>().Constants.CollapseField, "ContentName:" + id);

                   docs.Add(searchDocument);

                }