search

package
v0.33.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2023 License: AGPL-3.0, AGPL-3.0-only Imports: 30 Imported by: 0

README

meilisearch 的限制,>= 这些比较只能用在数字上,所以入库和搜索的时候 YYYY-MM-DD 格式的日期都会被转成 yyyymmdd 的 int,

会在对应索引不存在时自动创建索引,也可以使用 CHII_SEARCH_INIT=true 环境变量强制设置索引和导入所有条目。

Documentation

Overview

Package search 基于 meilisearch 提供搜索功能

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Handler
	OnSubjectUpdate(ctx context.Context, id model.SubjectID) error
	Close()
	OnSubjectDelete(ctx context.Context, id model.SubjectID) error
}

func New

func New(
	cfg config.AppConfig,
	subjectRepo subject.Repo,
	log *zap.Logger,
	query *query.Query,
) (Client, error)

New provide a search app is AppConfig.MeiliSearchURL is empty string, return nope search client.

see `MeiliSearchURL` and `MeiliSearchKey` in config.AppConfig.

type Handler

type Handler interface {
	Handle(c echo.Context) error
}

Handler TODO: 想个办法挪到 web 里面去.

type NoopClient

type NoopClient struct {
}

func (NoopClient) Close added in v0.29.10

func (n NoopClient) Close()

func (NoopClient) Handle

func (n NoopClient) Handle(c echo.Context) error

func (NoopClient) OnSubjectDelete

func (n NoopClient) OnSubjectDelete(_ context.Context, _ model.SubjectID) error

func (NoopClient) OnSubjectUpdate

func (n NoopClient) OnSubjectUpdate(_ context.Context, _ model.SubjectID) error

type ReponseSubject added in v0.32.8

type ReponseSubject struct {
	Date    string           `json:"date"`
	Image   string           `json:"image"`
	Type    uint8            `json:"type"`
	Summary string           `json:"summary"`
	Name    string           `json:"name"`
	NameCN  string           `json:"name_cn"`
	Tags    []res.SubjectTag `json:"tags"`
	Score   float64          `json:"score"`
	ID      model.SubjectID  `json:"id"`
	Rank    uint32           `json:"rank"`
}

type Req

type Req struct {
	Keyword string    `json:"keyword"`
	Sort    string    `json:"sort"`
	Filter  ReqFilter `json:"filter"`
}

type ReqFilter added in v0.25.6

type ReqFilter struct {
	Type    []model.SubjectType `json:"type"`     // or
	Tag     []string            `json:"tag"`      // and
	AirDate []string            `json:"air_date"` // and
	Score   []string            `json:"rating"`   // and
	Rank    []string            `json:"rank"`     // and
	NSFW    null.Bool           `json:"nsfw"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL