Skip to content

Commit

Permalink
Fixes #234
Browse files Browse the repository at this point in the history
  • Loading branch information
Shazwazza committed Jun 14, 2021
1 parent 71c0e88 commit 6fedcfd
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Examine.Lucene/Search/LuceneSearchExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ public ISearchResults Execute()
}
}

var maxResults = Math.Min(_options.Take, MaxDoc);
var maxResults = Math.Min(_options.Skip * _options.Take, MaxDoc);
maxResults = maxResults >= 1 ? maxResults : QueryOptions.DefaultMaxResults;

ICollector topDocsCollector;
var sortFields = _sortField as SortField[] ?? _sortField.ToArray();
SortField[] sortFields = _sortField as SortField[] ?? _sortField.ToArray();
if (sortFields.Length > 0)
{
topDocsCollector = TopFieldCollector.Create(
Expand All @@ -95,17 +95,14 @@ public ISearchResults Execute()
{
searcher.IndexSearcher.Search(_luceneQuery, topDocsCollector);

var skip = _options.Skip;
var take = maxResults;

TopDocs topDocs;
if (sortFields.Length > 0)
{
topDocs = ((TopFieldCollector)topDocsCollector).GetTopDocs(skip, take);
topDocs = ((TopFieldCollector)topDocsCollector).GetTopDocs(_options.Skip, _options.Take);
}
else
{
topDocs = ((TopScoreDocCollector)topDocsCollector).GetTopDocs(skip, take);
topDocs = ((TopScoreDocCollector)topDocsCollector).GetTopDocs(_options.Skip, _options.Take);
}

var totalItemCount = topDocs.TotalHits;
Expand Down

0 comments on commit 6fedcfd

Please sign in to comment.