Exemplo n.º 1
0
        public virtual IEnumerable <TModel> List()
        {
            var query = new MatchAllDocsQuery();

            using (var searcher = new IndexSearcher(Directory, true))
            {
                var filter = new QueryWrapperFilter(query);

                var hits = searcher.Search(query, filter, int.MaxValue).ScoreDocs;

                Logger.LogDebug($"Listing Lucene index returned {hits.Length} documents");

                return(hits.Select(h => _documentToModelMapper.Map(searcher.Doc(h.Doc))).ToList());
            }
        }
Exemplo n.º 2
0
        public virtual IEnumerable <TModel> Search(TQueryParameters queryParameters)
        {
            var searchCriteria = _searchCriteriaBuilder.Build(queryParameters);

            using (var searcher = new IndexSearcher(Directory, true))
            {
                var filter = new QueryWrapperFilter(searchCriteria.Query);

                var hits = searchCriteria.Sort == null
                    ? searcher.Search(searchCriteria.Query, filter, int.MaxValue).ScoreDocs
                    : searcher.Search(searchCriteria.Query, filter, int.MaxValue, searchCriteria.Sort).ScoreDocs;

                Logger.LogDebug($"Searching Lucene index with query: {searchCriteria.Query} and sort: {searchCriteria.Sort} returned {hits.Length} documents");

                return(hits.Select(h => _documentToModelMapper.Map(searcher.Doc(h.Doc))).ToList());
            }
        }