searchdb

package
v0.9.18 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

This package handles the retrieval of data from the CouchDB search database Synchronization is handled by triggers in the database using the http postgresql extension, without the need for postgres->application->couchdb->app->postgres- round trip (we need to store the returned document id to ensure deduplication)

Index

Constants

View Source
const (
	Members           targetDBName = "members"
	Artists           targetDBName = "artists"
	Ratings           targetDBName = "ratings"
	Genres            targetDBName = "genres"
	GenreDescriptions targetDBName = "genre_descriptions"
	// aka keywords
	Studios targetDBName = "studio"
	MediaDB targetDBName = "media"
)

Variables

nolint:gochecknoglobals

Functions

This section is empty.

Types

type AnonymousDocument added in v0.9.15

type AnonymousDocument struct {
	Type   string                 `json:"type"`
	Fields []interface{}          `json:"fields"`
	Data   map[string]interface{} `json:"data"`
}

AnonymousDocument is same as Ble

type Artist

type Artist struct {
	ID        string    `json:"_id" mapstructure:"-"`
	Rev       string    `json:"_rev" mapstructure:"-"`
	Name      string    `json:"name" mapstructure:"name"`
	Nicknames []string  `json:"nick_names" mapstructure:"nick_names"`
	Bio       string    `json:"bio" mapstructure:"bio"`
	Added     time.Time `json:"added" mapstructure:"added"`
	Modified  time.Time `json:"modified" mapstructure:"modified"`
}

type BleveDocument added in v0.9.15

type BleveDocument struct {
	// ID is the couchdb id of the document
	ID string `json:"id"`
	// Type is a field that allows us to distinguish between different types of documents
	Type string `json:"type"`
	// Fields is the list of additional fields that we can aggregate on
	Fields []interface{} `json:"fields"`
	// Data is the raw representation of the document
	Data map[string]interface{} `json:"data"`
}

func ToBleveDocument added in v0.9.15

func ToBleveDocument(combinedData *CombinedData, log *zerolog.Logger) (docs []BleveDocument, err error)

type CombinedData added in v0.9.15

type CombinedData struct {
	Genres  []Genre  `json:"genres" mapstructure:"genres"`
	Members []Member `json:"members" mapstructure:"members"`
	Studios []Studio `json:"studio" mapstructure:"studio"`
	Ratings []Rating `json:"ratings" mapstructure:"ratings"`
	Artists []Artist `json:"artists" mapstructure:"artists"`
	Media   []Media  `json:"media" mapstructure:"media"`
}

type Genre

type Genre struct {
	ID           string               `json:"_id" mapstructure:"-"`
	Rev          string               `json:"_rev" mapstructure:"-"`
	Name         string               `json:"name" mapstructure:"name"`
	Kinds        []string             `json:"kinds" mapstructure:"kinds"`
	Descriptions [][]GenreDescription `json:"descriptions" mapstructure:"descriptions"`
}

Those types are simplified representations of what is stored in postgres that are written to couchdb on insert/update

type GenreDescription

type GenreDescription struct {
	Description string `json:"description" mapstructure:"description"`
	Language    string `json:"language" mapstructure:"language"`
}

type Media

type Media struct {
	ID    string `json:"_id" mapstructure:"-"`
	Rev   string `json:"_rev" mapstructure:"-"`
	Title string `json:"title" mapstructure:"title"`
	Kind  string `json:"kind" mapstructure:"kind"`
	// Created refers to the release date
	Created  time.Time `json:"created" mapstructure:"created"`
	Added    time.Time `json:"added" mapstructure:"added"`
	Modified time.Time `json:"modified" mapstructure:"modified"`
}

type Member

type Member struct {
	ID          string `json:"_id" mapstructure:"-"`
	Rev         string `json:"_rev" mapstructure:"-"`
	Bio         string `json:"bio,omitempty" mapstructure:"bio,omitempty"`
	Webfinger   string `json:"webfinger,omitempty" mapstructure:"webfinger,omitempty"`
	DisplayName string `json:"display_name,omitempty" mapstructure:"display_name,omitempty"`
}

type Rating

type Rating struct {
	ID         string `json:"_id" mapstructure:"-"`
	Rev        string `json:"_rev" mapstructure:"-"`
	Topic      string `json:"topic" mapstructure:"topic"`
	Body       string `json:"body" mapstructure:"body"`
	User       string `json:"user" mapstructure:"user"`
	MediaTitle string `json:"media_title" mapstructure:"media_title"`
	// not sure whether this shouldn't actually be a string as well
	Added    time.Time `json:"added" mapstructure:"added"`
	Modified time.Time `json:"modified" mapstructure:"modified"`
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func Connect

func Connect(ctx context.Context, config *cfg.SearchConfig, log *zerolog.Logger) (*Storage, error)

func (*Storage) ReadAll

func (s *Storage) ReadAll(ctx context.Context) (data *CombinedData, err error)

we only care about scanning the data into it's raw JSON representation so that we can then use it for indexing

func (*Storage) ReadArtists

func (s *Storage) ReadArtists(ctx context.Context) (data []Artist, err error)

func (*Storage) ReadGenres

func (s *Storage) ReadGenres(ctx context.Context) (data []Genre, err error)

func (*Storage) ReadMedia

func (s *Storage) ReadMedia(ctx context.Context) (data []Media, err error)

func (*Storage) ReadMembers

func (s *Storage) ReadMembers(ctx context.Context) (data []Member, err error)

func (*Storage) ReadNew

func (s *Storage) ReadNew(
	ctx context.Context,
	outgoingDataFeed chan interface{},
	continuousMode bool,
) (err error)

ReadNew handles the cyclical or continuous retrieval of new documents for indexing. This function does not accept a target parameter, since it doesn't make much sense to only look for partial data. The channel parameter here is used to communicate data to the search indexer

func (*Storage) ReadRatings

func (s *Storage) ReadRatings(ctx context.Context) (data []Rating, err error)

func (*Storage) ReadStudios

func (s *Storage) ReadStudios(ctx context.Context) (data []Studio, err error)

type Studio

type Studio struct {
	ID       string    `json:"_id" mapstructure:"-"`
	Rev      string    `json:"_rev" mapstructure:"-"`
	Name     string    `json:"name" mapstructure:"name"`
	Kind     string    `json:"kind" mapstructure:"kind"`
	CityUUID string    `json:"city" mapstructure:"city"`
	Added    time.Time `json:"added" mapstructure:"added"`
	Modified time.Time `json:"modified" mapstructure:"modified"`
}

type TargetDB

type TargetDB interface {
	String() string
}

Jump to

Keyboard shortcuts

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