mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-21 21:05:18 +02:00
Bleve indexer support for searching issues with any assignee
This commit is contained in:
parent
a08f6b0c9e
commit
f350f1d852
@ -9,6 +9,7 @@ import (
|
|||||||
indexer_internal "code.gitea.io/gitea/modules/indexer/internal"
|
indexer_internal "code.gitea.io/gitea/modules/indexer/internal"
|
||||||
inner_bleve "code.gitea.io/gitea/modules/indexer/internal/bleve"
|
inner_bleve "code.gitea.io/gitea/modules/indexer/internal/bleve"
|
||||||
"code.gitea.io/gitea/modules/indexer/issues/internal"
|
"code.gitea.io/gitea/modules/indexer/issues/internal"
|
||||||
|
"code.gitea.io/gitea/modules/optional"
|
||||||
|
|
||||||
"github.com/blevesearch/bleve/v2"
|
"github.com/blevesearch/bleve/v2"
|
||||||
"github.com/blevesearch/bleve/v2/analysis/analyzer/custom"
|
"github.com/blevesearch/bleve/v2/analysis/analyzer/custom"
|
||||||
@ -236,7 +237,9 @@ func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (
|
|||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(options.PosterID.Value(), "poster_id"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.PosterID.Value(), "poster_id"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.AssigneeID.Has() {
|
if options.AnyAssigneeOnly {
|
||||||
|
queries = append(queries, inner_bleve.NumericRangeInclusiveQuery(optional.Some[int64](1), optional.None[int64](), "assignee_id"))
|
||||||
|
} else if options.AssigneeID.Has() {
|
||||||
queries = append(queries, inner_bleve.NumericEqualityQuery(options.AssigneeID.Value(), "assignee_id"))
|
queries = append(queries, inner_bleve.NumericEqualityQuery(options.AssigneeID.Value(), "assignee_id"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,6 +647,21 @@ var cases = []*testIndexerCase{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "SearchAnyAssignee",
|
||||||
|
SearchOptions: &internal.SearchOptions{
|
||||||
|
AnyAssigneeOnly: true,
|
||||||
|
},
|
||||||
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
assert.Len(t, result.Hits, 180)
|
||||||
|
for _, v := range result.Hits {
|
||||||
|
assert.GreaterOrEqual(t, data[v.ID].AssigneeID, int64(1))
|
||||||
|
}
|
||||||
|
assert.Equal(t, countIndexerData(data, func(v *internal.IndexerData) bool {
|
||||||
|
return v.AssigneeID >= 1
|
||||||
|
}), result.Total)
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type testIndexerCase struct {
|
type testIndexerCase struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user