Statement (meilisearch/filter.go)

gitea · modules/indexer/internal/meilisearch/filter.go · go · MIT
search

Copyright 2023 The Gitea Authors. All rights reserved. SPDX-License-Identifier: MIT

// Source: https://github.com/go-gitea/gitea | License: MIT | Copyright 2016 The Gitea Authors
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package meilisearch

import (
	"fmt"
	"strings"
)

// Filter represents a filter for meilisearch queries.
// It's just a simple wrapper around a string.
// DO NOT assume that it is a complete implementation.
type Filter interface {
	Statement() string
}

type FilterAnd struct {
	filters []Filter
}

func (f *FilterAnd) Statement() string {
	var statements []string
	for _, filter := range f.filters {
		if s := filter.Statement(); s != "" {
			statements = append(statements, fmt.Sprintf("(%s)", s))
		}
	}
	return strings.Join(statements, " AND ")

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key