Documentation
¶
Index ¶
- Constants
- func RunMigrations(ctx context.Context, client *opensearchapi.Client, migrations []Migration) error
- func Setup(ctx context.Context, client *opensearchapi.Client) error
- type BookIndex
- type BoolQuery
- type DateRangeQuery
- type FieldValue
- type HighlightField
- type HighlightRequest
- type Int32
- type MatchQuery
- type Migration
- type NumberRangeQuery
- type Query
- type QueryStringQuery
- type Range
- type RangeQuery
- type SearchReqBody
- type SearchRequest
- type SearchResult
- type SearchRow
- type SearchSort
- type SortOption
- type TermQuery
Constants ¶
View Source
const (
BOOKS_INDEX_NAME = "books"
)
Variables ¶
This section is empty.
Functions ¶
func RunMigrations ¶
RunMigrations runs unfinished migrations in the order they are provided. It stops at the first error. Migrations that have already finished are skipped.
Migration functions should be idempotent: a process can stop after a migration succeeds but before its completion is recorded, causing that migration to run again on the next attempt.
Types ¶
type BookIndex ¶
type BookIndex struct {
Name string `json:"name"`
Description string `json:"description"`
Rating string `json:"rating"`
AuthorID uuid.UUID `json:"authorId"`
Tags []int64 `json:"tags"`
Chapters int32 `json:"chapters"`
Words int32 `json:"words"`
Slug string `json:"slug"`
WordsPerChapter int32 `json:"wordsPerChapter"`
IsPubliclyVisible bool `json:"isPubliclyVisible"`
IsTrashed bool `json:"isTrashed"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Views int64 `json:"views"`
Popularity float64 `json:"popularity"`
ReadersCount int64 `json:"readersCount"`
ReviewsCount int64 `json:"reviewsCount"`
WeightedRating float64 `json:"weightedRating"`
}
type DateRangeQuery ¶
type FieldValue ¶
type FieldValue any
type HighlightField ¶
type HighlightField struct {
NumberOfFragments int `json:"number_of_fragments"`
}
type HighlightRequest ¶
type HighlightRequest struct {
PreTags []string `json:"pre_tags"`
PostTags []string `json:"post_tags"`
Encoder string `json:"encoder"`
Fields map[string]HighlightField `json:"fields"`
}
type MatchQuery ¶
type Migration ¶
Migration is a named, idempotent change to the OpenSearch store.
A migration is considered finished only after Run returns nil and its name has been recorded in OpenSearch. Names must be unique within a migration list and must not be changed after a migration has run.
type NumberRangeQuery ¶
type Query ¶
type Query struct {
Term map[string]TermQuery `json:"term,omitempty"`
Match map[string]MatchQuery `json:"match,omitempty"`
Bool *BoolQuery `json:"bool,omitempty"`
QueryString *QueryStringQuery `json:"query_string,omitempty"`
Range map[string]RangeQuery `json:"range,omitempty"`
}
type QueryStringQuery ¶
type QueryStringQuery struct {
Query string `json:"query"`
}
type RangeQuery ¶
type RangeQuery any
type SearchReqBody ¶
type SearchReqBody struct {
Highlight *HighlightRequest `json:"highlight,omitempty"`
Query Query `json:"query"`
From int `json:"from,omitempty"`
Size int `json:"size,omitempty"`
Sort []map[string]SortOption `json:"sort,omitempty"`
}
type SearchRequest ¶
type SearchRequest struct {
Rating string
NumberFilters map[string]*NumberRangeQuery
DateFilters map[string]DateRangeQuery
Query string
Sort SearchSort
IncludeUsers []string
ExcludeUsers []string
IncludeTags []int64
ExcludeTags []int64
Words Range
Chapters Range
WordsPerChapter Range
Page int32
PageSize int32
IncludeHidden bool
}
type SearchResult ¶
func Search ¶
func Search( ctx context.Context, client *opensearchapi.Client, req SearchRequest, ) (SearchResult, error)
type SearchSort ¶
type SearchSort string
const ( SearchSortChapters SearchSort = "chapters" SearchSortWords SearchSort = "words" SearchSortWordsPerChapter SearchSort = "words-per-chapter" )
type SortOption ¶
type SortOption struct {
Order string `json:"order"`
}
type TermQuery ¶
type TermQuery struct {
Value FieldValue `json:"value"`
}
Click to show internal directories.
Click to hide internal directories.