search

package
v0.28.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: AGPL-3.0, AGPL-3.0-only Imports: 26 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
	OnSubjectDelete(ctx context.Context, id model.SubjectID) error
}

func New

func New(
	c 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(ctx *fiber.Ctx, auth *accessor.Accessor) error
}

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

type NoopClient

type NoopClient struct {
}

func (NoopClient) Handle

func (n NoopClient) Handle(ctx *fiber.Ctx, auth *accessor.Accessor) error

func (NoopClient) OnSubjectDelete

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

func (NoopClient) OnSubjectUpdate

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

type Record

type Record struct {
	Date   string           `json:"date"`
	Image  string           `json:"image"`
	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