IResourceHighlighter IResourceHighlighterFactory.Create(ResourceHighlighterKind kind, ResourceSearchCriteria criteria, HighlighterConfiguration configuration)
        {
            if (kind == ResourceHighlighterKind.Null || criteria == null)
            {
                return(new NullResourceHighlighter());
            }

            var searchQuery  = criteria.GetSearchQuery(null);
            var contentQuery = new QueryBuilder(_defaultQueryAnalyzer).GetContentQuery(searchQuery);

            return(new ResourceHighlighter(contentQuery, _defaultContentAnalyzer, configuration));
        }
        /// <summary>
        /// Execute a search on the Lucene resource index
        /// </summary>
        /// <param name="criteria">The criteria the search results need to meet</param>
        /// <param name="range">The number of results to return. Null means include all resources</param>
        /// <returns>A list of resourceItemIds meeting the criteria</returns>
        ResourceSearchExecution IExecuteResourceSearchCommand.Search(ResourceSearchCriteria criteria, Range range)
        {
            ResourceSearchResults results;
            var service = _serviceManager.Create();

            try
            {
                results = service.Search(criteria.GetSearchQuery(range), true);
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);

            return(new ResourceSearchExecution
            {
                Criteria = criteria,
                Results = results,
            });
        }