A number of our clients partner with video providers like Brightcove or Ooyala. To sync the content between Sitecore and the video provider, Sitecore have provided a module called the Media Framework. We are using the Ooyala Edition. The framework adds a new template, OoyalaVideo, and the content items are stores in an Item Bucket inside the Media Library.
Because the items are in a bucket, to display a list we will use the SearchAPI to get lists of video items for display. The examples here are using Fortis and Lucene, but can easily be modified to Glass/Synthesis or straight Sitecore, and adapted to a SOLR implementation. Here is the code for a simple paged list of video items ordered by date descending or ascending:
public IEnumerable<IOoyalaVideo> GetVideos(
using (var searchContext = this.SearchManager.SearchContext)
All seemed to be working ok, except the sorting. It had no effect on the results being returned at all. On further investigation it turns out that the MediaFramework adds some custom fields to Sitecore.
On checking the index configuration - these new field types were not being added to the index, so none of the filters or sorts based on those filters were working.
So we updated the index configuration to have the new field types:
Rebuild the indexes and magically the sorting starts working again! Amazing what you can do when the fields are added into the index properly :)
###TL;DR When you are using the Media Framework module, Brightcode or Ooyala editions, make sure that any custom fields are included in the index configuration by fieldType if you want to use them in your search queries.