mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-07-12 23:19:19 +02:00
[v11/forgejo] fix: skip empty tokens in SearchOptions.Tokens() (#8412)
Some checks failed
testing / backend-checks (push) Has been cancelled
/ release (push) Has been cancelled
testing / frontend-checks (push) Has been cancelled
testing / test-unit (push) Has been cancelled
testing / test-e2e (push) Has been cancelled
testing / test-remote-cacher (redis) (push) Has been cancelled
testing / test-remote-cacher (valkey) (push) Has been cancelled
testing / test-remote-cacher (garnet) (push) Has been cancelled
testing / test-remote-cacher (redict) (push) Has been cancelled
testing / test-mysql (push) Has been cancelled
testing / test-pgsql (push) Has been cancelled
testing / test-sqlite (push) Has been cancelled
testing / security-check (push) Has been cancelled
Some checks failed
testing / backend-checks (push) Has been cancelled
/ release (push) Has been cancelled
testing / frontend-checks (push) Has been cancelled
testing / test-unit (push) Has been cancelled
testing / test-e2e (push) Has been cancelled
testing / test-remote-cacher (redis) (push) Has been cancelled
testing / test-remote-cacher (valkey) (push) Has been cancelled
testing / test-remote-cacher (garnet) (push) Has been cancelled
testing / test-remote-cacher (redict) (push) Has been cancelled
testing / test-mysql (push) Has been cancelled
testing / test-pgsql (push) Has been cancelled
testing / test-sqlite (push) Has been cancelled
testing / security-check (push) Has been cancelled
backport of #8261 to v11 Co-authored-by: Danko Aleksejevs <danko@very.lv> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8412 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda@noreply.codeberg.org> Co-committed-by: Shiny Nematoda <snematoda@noreply.codeberg.org>
This commit is contained in:
parent
0dc2bed2dd
commit
86b6553f3a
5 changed files with 146 additions and 16 deletions
|
@ -148,12 +148,13 @@ func (b *Indexer) Delete(ctx context.Context, ids ...int64) error {
|
|||
func (b *Indexer) Search(ctx context.Context, options *internal.SearchOptions) (*internal.SearchResult, error) {
|
||||
query := elastic.NewBoolQuery()
|
||||
|
||||
if options.Keyword != "" {
|
||||
tokens, err := options.Tokens()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(tokens) > 0 {
|
||||
q := elastic.NewBoolQuery()
|
||||
tokens, err := options.Tokens()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, token := range tokens {
|
||||
innerQ := elastic.NewMultiMatchQuery(token.Term, "title", "content", "comments")
|
||||
if token.Fuzzy {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue