Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and enhance issue indexer to support both searching, filtering and paging #26012

Merged
merged 108 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
7ae24a1
feat: IndexerMetadata
wolfogre Jun 16, 2023
1a13ce1
fix: use unique queue
wolfogre Jun 16, 2023
836ccf0
feat: query IndexerData
wolfogre Jun 16, 2023
d5c91d3
fix: new models
wolfogre Jun 16, 2023
3a2650f
feat: field for sorting
wolfogre Jul 5, 2023
9f464ed
fix: remove IsPublicRepo
wolfogre Jul 12, 2023
b1bcb88
fix: sortby
wolfogre Jul 12, 2023
ed16cd3
feat: add mapping
wolfogre Jul 12, 2023
84d6c0b
fix: build query
wolfogre Jul 13, 2023
29e3c7b
fix: label int64
wolfogre Jul 13, 2023
7a83ee9
feat: SearchIssues
wolfogre Jul 13, 2023
39c0769
test: use SearchIssues
wolfogre Jul 13, 2023
abdbfbe
fix: set default limit
wolfogre Jul 13, 2023
c6114f2
feat: RegisterFilterIssuesFunc
wolfogre Jul 13, 2023
f8f0b72
feat: WIP filterIssuesOfSearchResult
wolfogre Jul 13, 2023
668d831
feat: register db searching
wolfogre Jul 14, 2023
d547195
fix: db search
wolfogre Jul 14, 2023
b640caa
feat: db indexer
wolfogre Jul 14, 2023
da43c80
feat: db search
wolfogre Jul 14, 2023
0dcbb40
feat: ParsePaginator
wolfogre Jul 17, 2023
35eec57
fix: public repo
wolfogre Jul 17, 2023
a678836
feat: use SearchIssues
wolfogre Jul 17, 2023
840d7e3
fix: index issue
wolfogre Jul 17, 2023
2feead2
feat: getIssueIndexerData
wolfogre Jul 18, 2023
25eda69
feat: update option
wolfogre Jul 18, 2023
cff4ad6
feat: update issue indexer
wolfogre Jul 18, 2023
0a6c2d9
fix: docMapping
wolfogre Jul 18, 2023
fa35921
feat: bleve searching
wolfogre Jul 18, 2023
c97c8c2
chore: update bleve version
wolfogre Jul 18, 2023
f5e0f6c
fix: some fix
wolfogre Jul 18, 2023
0f1d898
fix: reuse SearchIssues in SearchIssuesByKeyword
wolfogre Jul 20, 2023
fad43d4
feat: web SearchIssues
wolfogre Jul 20, 2023
4c9af8b
fix: api ListIssues
wolfogre Jul 20, 2023
6953a68
feat: web ListIssues
wolfogre Jul 20, 2023
3af6404
fix: Paginator
wolfogre Jul 20, 2023
1df1ef4
feat: buildIssueOverview
wolfogre Jul 20, 2023
2b8aa89
fix: allIssueIDs
wolfogre Jul 20, 2023
4ca0660
feat: issues
wolfogre Jul 20, 2023
719173b
fix: meilisearch
wolfogre Jul 20, 2023
587c666
fix: applyLimit
wolfogre Jul 20, 2023
9bab931
fix: empty means SortByCreatedDesc
wolfogre Jul 20, 2023
86d8ee0
chore: remove SearchIssuesByKeyword
wolfogre Jul 20, 2023
4aa7fc7
chore: remove help comments
wolfogre Jul 20, 2023
e7e4edb
fix: lint code
wolfogre Jul 20, 2023
6473b31
test: fix case
wolfogre Jul 20, 2023
2759d46
test: fix case
wolfogre Jul 20, 2023
3c8cb1a
tests: new test framework for indexer
wolfogre Jul 20, 2023
dc8b61a
test: add comments
wolfogre Jul 20, 2023
3d00c2d
test: ExtraData
wolfogre Jul 20, 2023
5156771
test: tidy
wolfogre Jul 21, 2023
38c8024
test: empty
wolfogre Jul 21, 2023
0c8269e
fix: panic to read nil project
wolfogre Jul 21, 2023
c9d1399
fix: no label check
wolfogre Jul 21, 2023
6adf9d6
fix: meilisearch condition
wolfogre Jul 21, 2023
d18a68c
fix: db search
wolfogre Jul 21, 2023
e919d73
fix: db test
wolfogre Jul 21, 2023
6075007
fix: db searching
wolfogre Jul 21, 2023
535a691
fix: paginator
wolfogre Jul 21, 2023
4af28d6
fix: do default Paginator
wolfogre Jul 21, 2023
934c526
feat: use db if keyword is empty
wolfogre Jul 21, 2023
b7668aa
fix: applyLimit
wolfogre Jul 21, 2023
f6fec6b
test: cases for TestIndexer
wolfogre Jul 21, 2023
6a4999c
fix: LoadAttributes context
wolfogre Jul 21, 2023
f05b5b5
chore: lint code
wolfogre Jul 21, 2023
cb926ba
Merge branch 'main' into feature/enhance_issue_bleve_indexer
wolfogre Jul 24, 2023
05fb5f4
fix: filter by lables
wolfogre Jul 24, 2023
376a381
chore: add TBC
wolfogre Jul 24, 2023
8a64027
feat: IncludedAnyLabelIDs
wolfogre Jul 24, 2023
639a393
fix: use includedAnyLabels
wolfogre Jul 24, 2023
9618002
fix: load label names
wolfogre Jul 24, 2023
ee0fda4
Merge branch 'main' into feature/enhance_issue_bleve_indexer
wolfogre Jul 24, 2023
e840b6c
test: more cases
wolfogre Jul 24, 2023
28f1be6
fix: check IsAvailable
wolfogre Jul 24, 2023
e6383f3
test: more cases
wolfogre Jul 24, 2023
032363f
docs: add comments
wolfogre Jul 24, 2023
30a3375
debug: pq "gtestschema.label_issue" does not exist
wolfogre Jul 24, 2023
ddd5f2b
feat: improve enqueue
wolfogre Jul 25, 2023
37cf4c1
chore: use hotfix xorm
wolfogre Jul 25, 2023
ef27f6a
fix: es page size
wolfogre Jul 25, 2023
61b2317
Revert "chore: use hotfix xorm"
wolfogre Jul 26, 2023
fa03f68
Merge branch 'main' into feature/enhance_issue_bleve_indexer
wolfogre Jul 26, 2023
5797332
fix: fix unit test
wolfogre Jul 26, 2023
d4d540d
test: more cases
wolfogre Jul 26, 2023
f1b75ae
test: fix cases
wolfogre Jul 26, 2023
7369296
Merge branch 'main' into feature/enhance_issue_bleve_indexer
wolfogre Jul 26, 2023
0549ba3
feat: support elasticsearch
wolfogre Jul 26, 2023
4789728
feat: support es
wolfogre Jul 26, 2023
91ba549
feat: support meilisearch setting
wolfogre Jul 26, 2023
97e455f
test: waitData
wolfogre Jul 26, 2023
95e1f49
feat: settings for melisearch
wolfogre Jul 26, 2023
1e1328f
fix: accept es yellow
wolfogre Jul 27, 2023
bc7cb96
feat: support meilisearch
wolfogre Jul 27, 2023
da3a678
fix: RankingRules
wolfogre Jul 27, 2023
71d5ad2
chore: remove Imprecise
wolfogre Jul 27, 2023
c65718b
test: env for meilisearch
wolfogre Jul 27, 2023
439c798
chore: remove debug code
wolfogre Jul 27, 2023
70e780e
docs: add comments
wolfogre Jul 27, 2023
f12aba5
docs: add comments
wolfogre Jul 27, 2023
923b15f
chore: add meilisearch to hosts
wolfogre Jul 27, 2023
8f265d4
test: sleep when waiting
wolfogre Jul 27, 2023
8d386ce
Merge branch 'main' into feature/enhance_issue_bleve_indexer
wolfogre Jul 27, 2023
60638bb
Fix bug
lunny Jul 27, 2023
60fcb9c
Fix bug
lunny Jul 27, 2023
7010d53
fix: stats if zero found
wolfogre Jul 28, 2023
9473d81
Merge branch 'main' into feature/enhance_issue_bleve_indexer
wolfogre Jul 28, 2023
9b5f44f
Merge branch 'main' into feature/enhance_issue_bleve_indexer
GiteaBot Jul 31, 2023
dd71ef3
Merge branch 'main' into feature/enhance_issue_bleve_indexer
lunny Jul 31, 2023
9eeda00
Merge branch 'main' into feature/enhance_issue_bleve_indexer
techknowlogick Jul 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/pull-db-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ jobs:
discovery.type: single-node
ports:
- "9200:9200"
meilisearch:
image: getmeili/meilisearch:v1.2.0
env:
MEILI_ENV: development # disable auth
ports:
- "7700:7700"
smtpimap:
image: tabascoterrier/docker-imap-devel:latest
ports:
Expand Down Expand Up @@ -128,7 +134,7 @@ jobs:
go-version: ">=1.20"
check-latest: true
- name: Add hosts to /etc/hosts
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap" | sudo tee -a /etc/hosts'
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch meilisearch smtpimap" | sudo tee -a /etc/hosts'
- run: make deps-backend
- run: make backend
env:
Expand Down
17 changes: 17 additions & 0 deletions models/db/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,20 @@ func BuildCaseInsensitiveLike(key, value string) builder.Cond {
}
return builder.Like{"UPPER(" + key + ")", strings.ToUpper(value)}
}

// BuildCaseInsensitiveIn returns a condition to check if the given value is in the given values case-insensitively.
// Handles especially SQLite correctly as UPPER there only transforms ASCII letters.
func BuildCaseInsensitiveIn(key string, values []string) builder.Cond {
uppers := make([]string, 0, len(values))
if setting.Database.Type.IsSQLite3() {
for _, value := range values {
uppers = append(uppers, util.ToUpperASCII(value))
}
} else {
for _, value := range values {
uppers = append(uppers, strings.ToUpper(value))
}
}

return builder.In("UPPER("+key+")", uppers)
}
26 changes: 24 additions & 2 deletions models/issues/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
project_model "code.gitea.io/gitea/models/project"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
Expand Down Expand Up @@ -550,9 +551,30 @@ func GetIssueWithAttrsByID(id int64) (*Issue, error) {
}

// GetIssuesByIDs return issues with the given IDs.
func GetIssuesByIDs(ctx context.Context, issueIDs []int64) (IssueList, error) {
// If keepOrder is true, the order of the returned issues will be the same as the given IDs.
func GetIssuesByIDs(ctx context.Context, issueIDs []int64, keepOrder ...bool) (IssueList, error) {
issues := make([]*Issue, 0, len(issueIDs))
return issues, db.GetEngine(ctx).In("id", issueIDs).Find(&issues)

if err := db.GetEngine(ctx).In("id", issueIDs).Find(&issues); err != nil {
return nil, err
}

if len(keepOrder) > 0 && keepOrder[0] {
m := make(map[int64]*Issue, len(issues))
appended := container.Set[int64]{}
for _, issue := range issues {
m[issue.ID] = issue
}
issues = issues[:0]
for _, id := range issueIDs {
if issue, ok := m[id]; ok && !appended.Contains(id) { // make sure the id is existed and not appended
appended.Add(id)
issues = append(issues, issue)
}
}
}

return issues, nil
}

// GetIssueIDsByRepoID returns all issue ids by repo id
Expand Down
81 changes: 36 additions & 45 deletions models/issues/issue_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

// IssuesOptions represents options of an issue.
type IssuesOptions struct { //nolint
db.ListOptions
db.Paginator
RepoIDs []int64 // overwrites RepoCond if the length is not 0
RepoCond builder.Cond
AssigneeID int64
Expand Down Expand Up @@ -99,15 +99,28 @@ func applySorts(sess *xorm.Session, sortType string, priorityRepoID int64) {
}

func applyLimit(sess *xorm.Session, opts *IssuesOptions) *xorm.Session {
if opts.Page >= 0 && opts.PageSize > 0 {
var start int
if opts.Page == 0 {
start = 0
} else {
start = (opts.Page - 1) * opts.PageSize
if opts.Paginator == nil || opts.Paginator.IsListAll() {
return sess
}

// Warning: Do not use GetSkipTake() for *db.ListOptions
// Its implementation could reset the page size with setting.API.MaxResponseItems
if listOptions, ok := opts.Paginator.(*db.ListOptions); ok {
if listOptions.Page >= 0 && listOptions.PageSize > 0 {
var start int
if listOptions.Page == 0 {
start = 0
} else {
start = (listOptions.Page - 1) * listOptions.PageSize
}
sess.Limit(listOptions.PageSize, start)
}
sess.Limit(opts.PageSize, start)
return sess
}

start, limit := opts.Paginator.GetSkipTake()
sess.Limit(limit, start)

return sess
}

Expand Down Expand Up @@ -435,7 +448,7 @@ func Issues(ctx context.Context, opts *IssuesOptions) ([]*Issue, error) {
applyConditions(sess, opts)
applySorts(sess, opts.SortType, opts.PriorityRepoID)

issues := make(IssueList, 0, opts.ListOptions.PageSize)
issues := IssueList{}
if err := sess.Find(&issues); err != nil {
return nil, fmt.Errorf("unable to query Issues: %w", err)
}
Expand All @@ -447,45 +460,23 @@ func Issues(ctx context.Context, opts *IssuesOptions) ([]*Issue, error) {
return issues, nil
}

// SearchIssueIDsByKeyword search issues on database
func SearchIssueIDsByKeyword(ctx context.Context, kw string, repoIDs []int64, limit, start int) (int64, []int64, error) {
repoCond := builder.In("repo_id", repoIDs)
subQuery := builder.Select("id").From("issue").Where(repoCond)
cond := builder.And(
repoCond,
builder.Or(
db.BuildCaseInsensitiveLike("name", kw),
db.BuildCaseInsensitiveLike("content", kw),
builder.In("id", builder.Select("issue_id").
From("comment").
Where(builder.And(
builder.Eq{"type": CommentTypeComment},
builder.In("issue_id", subQuery),
db.BuildCaseInsensitiveLike("content", kw),
)),
),
),
)

ids := make([]int64, 0, limit)
res := make([]struct {
ID int64
UpdatedUnix int64
}, 0, limit)
err := db.GetEngine(ctx).Distinct("id", "updated_unix").Table("issue").Where(cond).
OrderBy("`updated_unix` DESC").Limit(limit, start).
Find(&res)
if err != nil {
return 0, nil, err
}
for _, r := range res {
ids = append(ids, r.ID)
// IssueIDs returns a list of issue ids by given conditions.
func IssueIDs(ctx context.Context, opts *IssuesOptions, otherConds ...builder.Cond) ([]int64, int64, error) {
sess := db.GetEngine(ctx).
Join("INNER", "repository", "`issue`.repo_id = `repository`.id")
applyConditions(sess, opts)
for _, cond := range otherConds {
sess.And(cond)
}

total, err := db.GetEngine(ctx).Distinct("id").Table("issue").Where(cond).Count()
applyLimit(sess, opts)
applySorts(sess, opts.SortType, opts.PriorityRepoID)

var res []int64
total, err := sess.Select("`issue`.id").Table(&Issue{}).FindAndCount(&res)
if err != nil {
return 0, nil, err
return nil, 0, err
}

return total, ids, nil
return res, total, nil
}
47 changes: 18 additions & 29 deletions models/issues/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestIssueAPIURL(t *testing.T) {
func TestGetIssuesByIDs(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
testSuccess := func(expectedIssueIDs, nonExistentIssueIDs []int64) {
issues, err := issues_model.GetIssuesByIDs(db.DefaultContext, append(expectedIssueIDs, nonExistentIssueIDs...))
issues, err := issues_model.GetIssuesByIDs(db.DefaultContext, append(expectedIssueIDs, nonExistentIssueIDs...), true)
assert.NoError(t, err)
actualIssueIDs := make([]int64, len(issues))
for i, issue := range issues {
Expand All @@ -83,6 +83,7 @@ func TestGetIssuesByIDs(t *testing.T) {
}
testSuccess([]int64{1, 2, 3}, []int64{})
testSuccess([]int64{1, 2, 3}, []int64{unittest.NonexistentID})
testSuccess([]int64{3, 2, 1}, []int64{})
}

func TestGetParticipantIDsByIssue(t *testing.T) {
Expand Down Expand Up @@ -165,7 +166,7 @@ func TestIssues(t *testing.T) {
issues_model.IssuesOptions{
RepoCond: builder.In("repo_id", 1, 3),
SortType: "oldest",
ListOptions: db.ListOptions{
Paginator: &db.ListOptions{
Page: 1,
PageSize: 4,
},
Expand All @@ -175,7 +176,7 @@ func TestIssues(t *testing.T) {
{
issues_model.IssuesOptions{
LabelIDs: []int64{1},
ListOptions: db.ListOptions{
Paginator: &db.ListOptions{
Page: 1,
PageSize: 4,
},
Expand All @@ -185,7 +186,7 @@ func TestIssues(t *testing.T) {
{
issues_model.IssuesOptions{
LabelIDs: []int64{1, 2},
ListOptions: db.ListOptions{
Paginator: &db.ListOptions{
Page: 1,
PageSize: 4,
},
Expand Down Expand Up @@ -333,30 +334,6 @@ func TestIssue_loadTotalTimes(t *testing.T) {
assert.Equal(t, int64(3682), ms.TotalTrackedTime)
}

func TestIssue_SearchIssueIDsByKeyword(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
total, ids, err := issues_model.SearchIssueIDsByKeyword(context.TODO(), "issue2", []int64{1}, 10, 0)
assert.NoError(t, err)
assert.EqualValues(t, 1, total)
assert.EqualValues(t, []int64{2}, ids)

total, ids, err = issues_model.SearchIssueIDsByKeyword(context.TODO(), "first", []int64{1}, 10, 0)
assert.NoError(t, err)
assert.EqualValues(t, 1, total)
assert.EqualValues(t, []int64{1}, ids)

total, ids, err = issues_model.SearchIssueIDsByKeyword(context.TODO(), "for", []int64{1}, 10, 0)
assert.NoError(t, err)
assert.EqualValues(t, 5, total)
assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids)

// issue1's comment id 2
total, ids, err = issues_model.SearchIssueIDsByKeyword(context.TODO(), "good", []int64{1}, 10, 0)
assert.NoError(t, err)
assert.EqualValues(t, 1, total)
assert.EqualValues(t, []int64{1}, ids)
}

func TestGetRepoIDsForIssuesOptions(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
Expand Down Expand Up @@ -496,7 +473,19 @@ func TestCorrectIssueStats(t *testing.T) {
wg.Wait()

// Now we will get all issueID's that match the "Bugs are nasty" query.
total, ids, err := issues_model.SearchIssueIDsByKeyword(context.TODO(), "Bugs are nasty", []int64{1}, issueAmount, 0)
issues, err := issues_model.Issues(context.TODO(), &issues_model.IssuesOptions{
Paginator: &db.ListOptions{
PageSize: issueAmount,
},
RepoIDs: []int64{1},
})
total := int64(len(issues))
var ids []int64
for _, issue := range issues {
if issue.Content == "Bugs are nasty" {
ids = append(ids, issue.ID)
}
}

// Just to be sure.
assert.NoError(t, err)
Expand Down
10 changes: 10 additions & 0 deletions models/issues/issue_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,13 @@ func UpdateIssueUsersByMentions(ctx context.Context, issueID int64, uids []int64
}
return nil
}

// GetIssueMentionIDs returns all mentioned user IDs of an issue.
func GetIssueMentionIDs(ctx context.Context, issueID int64) ([]int64, error) {
var ids []int64
return ids, db.GetEngine(ctx).Table(IssueUser{}).
Where("issue_id=?", issueID).
And("is_mentioned=?", true).
Select("uid").
Find(&ids)
}
16 changes: 14 additions & 2 deletions models/issues/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ func GetLabelByID(ctx context.Context, labelID int64) (*Label, error) {
}

// GetLabelsByIDs returns a list of labels by IDs
func GetLabelsByIDs(labelIDs []int64) ([]*Label, error) {
func GetLabelsByIDs(labelIDs []int64, cols ...string) ([]*Label, error) {
labels := make([]*Label, 0, len(labelIDs))
return labels, db.GetEngine(db.DefaultContext).Table("label").
In("id", labelIDs).
Asc("name").
Cols("id", "repo_id", "org_id").
Cols(cols...).
Find(&labels)
}

Expand Down Expand Up @@ -476,6 +476,18 @@ func GetLabelsByOrgID(ctx context.Context, orgID int64, sortType string, listOpt
return labels, sess.Find(&labels)
}

// GetLabelIDsByNames returns a list of labelIDs by names.
// It doesn't filter them by repo or org, so it could return labels belonging to different repos/orgs.
// It's used for filtering issues via indexer, otherwise it would be useless.
// Since it could return labels with the same name, so the length of returned ids could be more than the length of names.
func GetLabelIDsByNames(ctx context.Context, labelNames []string) ([]int64, error) {
labelIDs := make([]int64, 0, len(labelNames))
return labelIDs, db.GetEngine(ctx).Table("label").
In("name", labelNames).
Cols("id").
Find(&labelIDs)
}

// CountLabelsByOrgID count all labels that belong to given organization by ID.
func CountLabelsByOrgID(orgID int64) (int64, error) {
return db.GetEngine(db.DefaultContext).Where("org_id = ?", orgID).Count(&Label{})
Expand Down
12 changes: 12 additions & 0 deletions models/issues/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,18 @@ func GetMilestones(opts GetMilestonesOption) (MilestoneList, int64, error) {
return miles, total, err
}

// GetMilestoneIDsByNames returns a list of milestone ids by given names.
// It doesn't filter them by repo, so it could return milestones belonging to different repos.
// It's used for filtering issues via indexer, otherwise it would be useless.
// Since it could return milestones with the same name, so the length of returned ids could be more than the length of names.
func GetMilestoneIDsByNames(ctx context.Context, names []string) ([]int64, error) {
var ids []int64
return ids, db.GetEngine(ctx).Table("milestone").
Where(db.BuildCaseInsensitiveIn("name", names)).
Cols("id").
Find(&ids)
}

// SearchMilestones search milestones
func SearchMilestones(repoCond builder.Cond, page int, isClosed bool, sortType, keyword string) (MilestoneList, error) {
miles := make([]*Milestone, 0, setting.UI.IssuePagingNum)
Expand Down
13 changes: 2 additions & 11 deletions modules/indexer/code/bleve/bleve.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ const (
maxBatchSize = 16
)

// numericEqualityQuery a numeric equality query for the given value and field
func numericEqualityQuery(value int64, field string) *query.NumericRangeQuery {
f := float64(value)
tru := true
q := bleve.NewNumericRangeInclusiveQuery(&f, &f, &tru, &tru)
q.SetField(field)
return q
}

func addUnicodeNormalizeTokenFilter(m *mapping.IndexMappingImpl) error {
return m.AddCustomTokenFilter(unicodeNormalizeName, map[string]any{
"type": unicodenorm.Name,
Expand Down Expand Up @@ -225,7 +216,7 @@ func (b *Indexer) Index(ctx context.Context, repo *repo_model.Repository, sha st

// Delete deletes indexes by ids
func (b *Indexer) Delete(_ context.Context, repoID int64) error {
query := numericEqualityQuery(repoID, "RepoID")
query := inner_bleve.NumericEqualityQuery(repoID, "RepoID")
searchRequest := bleve.NewSearchRequestOptions(query, 2147483647, 0, false)
result, err := b.inner.Indexer.Search(searchRequest)
if err != nil {
Expand Down Expand Up @@ -262,7 +253,7 @@ func (b *Indexer) Search(ctx context.Context, repoIDs []int64, language, keyword
if len(repoIDs) > 0 {
repoQueries := make([]query.Query, 0, len(repoIDs))
for _, repoID := range repoIDs {
repoQueries = append(repoQueries, numericEqualityQuery(repoID, "RepoID"))
repoQueries = append(repoQueries, inner_bleve.NumericEqualityQuery(repoID, "RepoID"))
}

indexerQuery = bleve.NewConjunctionQuery(
Expand Down
Loading