Sunday, 10 November 2013

Retrieve VideoSetEmbedCode using Search API

I've created new asset library in SharePoint , when I upload a new video I have the option to select an embed video , when I try to query the video Item using Search RESTful API The VideoSetEmbedCode is not appearing , below is the troubleshooting steps i did to overcome the problem

  1. Open the Central administration
  2. Click on Manage service Application
  3. Manage Search service Application
  4. Click on Search Schema
  5. Try To search for managed property (no luck)
  6. Try to search for crawled property (no luck)
  7. using the powershell I retrieved the Video Item and it got he property ows_VideoSetEmbedCode so why this crawled property is not appearing in the search schema 
  8. I find out that the Field is hidden so I tried to unhide it using powershell and failed
  9. it turns out that CanToggleHidden is set to false so I used the below code to make it unhidden
  10.  using (SPSite  site=new SPSite("http://sp:2020"))
                {
    
    
                    SPList list = site.RootWeb.Lists["MediaLibrary"];
                    SPField videoField = list.Fields.GetFieldByInternalName("VideoSetEmbedCode");
    
                    Type type = videoField.GetType();
                    MethodInfo mi = type.GetMethod("SetFieldBoolValue", BindingFlags.NonPublic | BindingFlags.Instance);
                    mi.Invoke(videoField, new object[] { "CanToggleHidden", true });
                    videoField.Hidden = false;
                    videoField.Update();
    
                   
               
                }
    
    
    I performed full crawling and now it works I can retrieve the VideoSetEmbedCode using Search API (Restful /KeywordQuery)


Related Articles