From 0950c9ce38d26133228ce3aec028a75a29dfa61a Mon Sep 17 00:00:00 2001 From: Thomas Miceli <27960254+thomiceli@users.noreply.github.com> Date: Sat, 7 Sep 2024 14:36:16 +0200 Subject: [PATCH] Fix search unlisted gists (#319) --- internal/index/bleve.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/internal/index/bleve.go b/internal/index/bleve.go index 9abcc29..21b2293 100644 --- a/internal/index/bleve.go +++ b/internal/index/bleve.go @@ -98,20 +98,18 @@ func SearchGists(queryStr string, queryMetadata SearchGistMetadata, gistsIds []u indexerQuery = contentQuery } - if len(gistsIds) > 0 { - repoQueries := make([]query.Query, 0, len(gistsIds)) + repoQueries := make([]query.Query, 0, len(gistsIds)) - truee := true - for _, id := range gistsIds { - f := float64(id) - qq := bleve.NewNumericRangeInclusiveQuery(&f, &f, &truee, &truee) - qq.SetField("GistID") - repoQueries = append(repoQueries, qq) - } - - indexerQuery = bleve.NewConjunctionQuery(bleve.NewDisjunctionQuery(repoQueries...), indexerQuery) + truee := true + for _, id := range gistsIds { + f := float64(id) + qq := bleve.NewNumericRangeInclusiveQuery(&f, &f, &truee, &truee) + qq.SetField("GistID") + repoQueries = append(repoQueries, qq) } + indexerQuery = bleve.NewConjunctionQuery(bleve.NewDisjunctionQuery(repoQueries...), indexerQuery) + addQuery := func(field, value string) { if value != "" && value != "." { q := bleve.NewMatchPhraseQuery(value)