title: Select media returns no item in Sitecore - how to add facets?
body: <p>We recently upgraded our Sitecore from 6.5 to 7.1 .
  In the new version the interface for upload and selecting image has changed.
  When you upload an image and try to search to select it. It says "no items found"
  did anyone experience the same issue? How did you fixed it?</p>
  
  <p>I installed the fresh version of Sitecore 7.1 and I don't have this problem.</p>
  
  <p>I have a feeling that it should be an indexing config or building index for media library items. When you inspect the requests to Sitecore, the following url</p>
  
  <pre><code>/-/item/v1/sitecore/shell?facetsRootItemId=%7B7F43D3D0-CAC6-45D8-96FE-B76F4A117F9B%7D&amp;search=%7B%22statusCode%22%3A500%2C%22error%22%3A%7B%22message%22%3A%22Index%20sitecore_master_index%20was%20not%20found%22%7D%7D&amp;root=%7B3D6658D8-A0BF-4E75-B3E2-D050FABCF4E1%7D&amp;searchConfig=%7BB0DF45DF-EA31-4C11-9E34-98B41DF549C5%7D&amp;sc_content=master&amp;language=en&amp;format=%24convert_date_to_friendly_format&amp;fields=__Created%7CDimensions&amp;pageIndex=0&amp;pageSize=20
  </code></pre>
  
  <p>returns</p>
  
  <p>{"statusCode":200,"result":{"totalCount":0,"resultCount":0,"items":[],"facets":[{"Name":"Dimensions","Values":[]},{"Name":"Media Type","Values":[]},{"Name":"Updated","Values":[{"Count":0,"DisplayText":"Today","Priority":1,"Text":"Today","Value":"__smallupdateddate:[20140114 TO 20140114]"},{"Count":0,"DisplayText":"Yesterday","Priority":2,"Text":"Yesterday","Value":"__smallupdateddate:[20140113 TO 20140113]"},{"Count":0,"DisplayText":"Few days ago","Priority":3,"Text":"Few days ago","Value":"__smallupdateddate:[20140110 TO 20140112]"},{"Count":0,"DisplayText":"Last month","Priority":4,"Text":"Last month","Value":"__smallupdateddate:[20131214 TO 20140109]"},{"Count":0,"DisplayText":"Few months ago","Priority":5,"Text":"Few months ago","Value":"__smallupdateddate:[20130914 TO 20131213]"},{"Count":0,"DisplayText":"Older","Priority":6,"Text":"Older","Value":"__smallupdateddate:[00010101 TO 20130913]"}]}]}}</p>
  
  <p><img src="https://i.stack.imgur.com/ggdjc.png" alt="enter image description here"></p>
  
  <p>I checked the log and noticed when Sitecore tries to index media items it throws following exception</p>
  
  <pre><code>8328 16:37:58 ERROR Could not run the 'getMediaStream' pipeline for '/sitecore/media library/Files/Investors/Reports and Presentations/Prospectus/2009/MAp 2009 Entitlement Offer Booklet 20091014'. Original media data will be used.
  Exception: System.Data.SqlClient.SqlException
  Message: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The wait operation timed out.)
  Source: .Net SqlClient Data Provider
     at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)
     at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)
     at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&amp; connection)
     at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
     at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
     at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
     at System.Data.SqlClient.SqlConnection.Open()
     at Sitecore.Data.SqlServer.SqlServerDataProvider.GetBlobSize(Guid blobId)
     at Sitecore.Data.SqlServer.SqlServerDataProvider.GetBlobStream(Guid blobId, CallContext context)
     at Sitecore.Data.DataProviders.DataProvider.GetBlobStream(Guid blobId, CallContext context, DataProviderCollection providers)
     at Sitecore.Data.DataSource.GetBlobStream(Guid blobId)
     at Sitecore.Nexus.Data.DataCommands.GetBlobStreamCommand.Execute(Guid ?, Database )
     at Sitecore.Nexus.Data.NexusDataApi.GetBlobStream(Guid blobId, Database database)
     at Sitecore.Data.Engines.DataCommands.GetBlobStreamCommand.DoExecute()
     at Sitecore.Data.Engines.EngineCommand`2.Execute()
     at Sitecore.Data.Engines.DataEngine.GetBlobStream(Guid blobId)
     at Sitecore.Data.Managers.ItemProvider.GetBlobStream(Guid blobId, Database database)
     at Sitecore.Data.Managers.ItemManager.GetBlobStream(Guid blobId, Database database)
     at Sitecore.Data.Managers.ItemManager.GetBlobStream(Field field)
     at Sitecore.Resources.Media.MediaData.GetBlobStream()
     at Sitecore.Resources.Media.GetMediaStreamPipelineArgs.get_OutputStream()
     at Sitecore.Resources.Media.ResizeProcessor.Process(GetMediaStreamPipelineArgs args)
     at (Object , Object[] )
     at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
     at Sitecore.Resources.Media.Media.GetStreamFromPipeline(MediaOptions options, Boolean&amp; canBeCached)
  
  Nested Exception
  
  Exception: System.ComponentModel.Win32Exception
  </code></pre>
  
  <hr>
  
  <p>Sitecore got back to us with the following response. I'll keep you posted in case if you are experiencing same issue.</p>
  
  <p>getMediaStream retrieves the media data (the file itself) from database. It looks like you have faced the bug that content search does not close media stream which leads to the db connections leak. This bug is fixed in Sitecore 7.0 update 3 however it is not merged into sitecore 7.1 yet.</p>