From ade13d6422da3c64c2be46d69092bc1733febd00 Mon Sep 17 00:00:00 2001 From: Kleissner Date: Tue, 14 Dec 2021 17:48:59 +0100 Subject: [PATCH] Search results: Immediately (with results) signal if no more results will be available (search terminated). --- webapi/Search Job.go | 2 +- webapi/Search.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/webapi/Search Job.go b/webapi/Search Job.go index 80f1f9f..9a79dcf 100644 --- a/webapi/Search Job.go +++ b/webapi/Search Job.go @@ -359,7 +359,7 @@ func (job *SearchJob) IsTerminated() bool { // } // } - return false + return job.Status == SearchStatusTerminated || job.Status == SearchStatusNoIndex } // Terminate terminates all searches diff --git a/webapi/Search.go b/webapi/Search.go index 3c44761..b954f4c 100644 --- a/webapi/Search.go +++ b/webapi/Search.go @@ -171,7 +171,11 @@ func apiSearchResult(w http.ResponseWriter, r *http.Request) { // set the status if len(result.Files) > 0 { - result.Status = 0 // 0 = Success with results + if job.IsSearchResults() { + result.Status = 0 // 0 = Success with results + } else { + result.Status = 1 // No more results to expect + } } else { switch job.Status { case SearchStatusLive: @@ -185,8 +189,6 @@ func apiSearchResult(w http.ResponseWriter, r *http.Request) { } } - //if !job.IsSearchResults() { // if no fresh results to be expected - // embedded statistics? if returnStats, _ := strconv.ParseBool(r.Form.Get("stats")); returnStats { result.Statistic = job.Statistics()