searchservice

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const Index = "articles"

Variables

This section is empty.

Functions

func BuildSingleArticleSearchDocument

func BuildSingleArticleSearchDocument(article *articles.Entity) (*meilisearch.TaskInfo, error)

Types

type ArticleSearchDocument

type ArticleSearchDocument struct {
	ID            uint64   `json:"id"`
	Title         string   `json:"title"`         // 主要搜索字段
	SearchContent string   `json:"searchContent"` // 优化后的搜索文本
	Type          int8     `json:"type"`          // 可过滤字段
	ArticleStatus int8     `json:"articleStatus"` // 可过滤字段
	ProcessStatus int8     `json:"processStatus"` // 可过滤字段
	Category      []uint64 `json:"category"`
	CreatedAt     int64    `json:"createdAt"` // 时间戳(Unix)
	UpdatedAt     int64    `json:"updatedAt"` // 时间戳(Unix)
}

ArticleSearchDocument 文章搜索文档结构

type IndexBuildResult

type IndexBuildResult struct {
	ProcessedCount int    `json:"processedCount"`
	FailedCount    int    `json:"failedCount"`
	TotalBatches   int    `json:"totalBatches"`
	IndexName      string `json:"indexName"`
}

IndexBuildResult summarizes a Meilisearch rebuild.

func BuildMeilisearchIndex

func BuildMeilisearchIndex() (*IndexBuildResult, error)

BuildMeilisearchIndex rebuilds the Meilisearch article index.

type SearchRequest

type SearchRequest struct {
	Query      string   `json:"query"`
	Categories []uint64 `json:"categories"`
	Limit      int      `json:"limit"`
	Offset     int      `json:"offset"`
}

SearchRequest is an article search request.

type SearchResponse

type SearchResponse struct {
	Results []SearchResult `json:"results"`
	Total   int64          `json:"total"`
}

SearchResponse is the article search response.

func SearchArticles

func SearchArticles(req SearchRequest) (*SearchResponse, error)

SearchArticles returns article IDs and titles directly from Meilisearch.

type SearchResult

type SearchResult struct {
	ID    uint64 `json:"id"`
	Title string `json:"title"`
}

SearchResult is one search hit.

Jump to

Keyboard shortcuts

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