protected void btnDeleteIndex_Click(object sender, EventArgs e)
        {
            //this method wil only work if the index process is not currently
            //running
            Button button = (Button)sender;
            string cmdArg = button.CommandArgument;

            SearchQuery sq = new SearchQuery();
            if (!sq.DeleteIndex(Int32.Parse(cmdArg)))
                lblDeleteOutput.Text = "Index not deleted, the index is being crawled. Try again in a minute";
            else
                lblDeleteOutput.Text = "Index has been deleted";
        }
        /// <summary>
        /// Searches the index for stories kicked by a given user
        /// </summary>
        /// <param name="query"></param>
        /// <param name="username"></param>
        /// <param name="hostId"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public static StoryCollection GetStoryCollectionSearchResultsByUser(string query, string username, string sortField, 
            bool sortReversed, int hostId, int page, int pageSize)
        {
            string cacheKey = string.Format("SearchUserStoryCollection_{0}_{1}_{2}_{3}_{4}_{5}_{6}",
                                            CleanUpQuery(query),
                                            hostId,
                                            page,
                                            pageSize,
                                            username,
                                            sortField,
                                            sortReversed);

            string cacheCountKey = string.Format("SearchUserStoryCollectionCount_{0}_{1}_{2}", CleanUpQuery(query), hostId, username);

            CacheManager<string, StoryCollection> cache = GetSearchStoryCollectionCache();
            StoryCollection results = cache[cacheKey];
            if (results == null)
            {
                int totalNumberResults = 0;
                SearchQuery searchQuery = new SearchQuery();
                results = searchQuery.SearchIndex(hostId, query, username, page, pageSize, sortField, sortReversed, out totalNumberResults);

                if (results != null)
                {
                    cache.Insert(cacheKey, results, CacheHelper.CACHE_DURATION_IN_SECONDS);
                }

                //add to the cache containing the search results counts, we dont want to have to call the
                //the search twice since we already have this value in this method call.
                CacheManager<string, int?> cacheCount = GetSearchStoryCountCache();
                if (cacheCount.ContainsKey(cacheCountKey))
                    cacheCount.Remove(cacheCountKey);

                cacheCount.Insert(cacheCountKey, totalNumberResults, CacheHelper.CACHE_DURATION_IN_SECONDS);

            }

            return results;
        }