From 6fedcfd2b20e6763cb2b18176fd47c6c57a9c206 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 14 Jun 2021 12:30:05 -0600 Subject: [PATCH] Fixes #234 --- src/Examine.Lucene/Search/LuceneSearchExecutor.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Examine.Lucene/Search/LuceneSearchExecutor.cs b/src/Examine.Lucene/Search/LuceneSearchExecutor.cs index f3541f27f..7e5af5cb2 100644 --- a/src/Examine.Lucene/Search/LuceneSearchExecutor.cs +++ b/src/Examine.Lucene/Search/LuceneSearchExecutor.cs @@ -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( @@ -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;