Documentation
¶
Overview ¶
Package index provides interfaces for indexing documents metadata and retrieving this metadata back from the index. Currently, there is only one implementation to those interfaces, using Bleve.
Index ¶
- Constants
- func Create(path string) bleve.Index
- func CreateMapping() mapping.IndexMapping
- type Author
- type BleveIndexer
- func (b *BleveIndexer) AddFile(file string) (string, error)
- func (b *BleveIndexer) AddLibrary(batchSize int, forceIndexing bool) error
- func (b *BleveIndexer) Author(slug, lang string) (Author, error)
- func (b *BleveIndexer) Close() error
- func (b *BleveIndexer) Count(t string) (uint64, error)
- func (b *BleveIndexer) Document(slug string) (Document, error)
- func (b *BleveIndexer) Documents(IDs []string) (map[string]Document, error)
- func (b *BleveIndexer) IndexAuthor(author Author) error
- func (b *BleveIndexer) IndexingProgress() (Progress, error)
- func (b *BleveIndexer) RemoveFile(file string) error
- func (b *BleveIndexer) SameAuthors(slugID string, quantity int) ([]Document, error)
- func (b *BleveIndexer) SameSeries(slugID string, quantity int) ([]Document, error)
- func (b *BleveIndexer) SameSubjects(slugID string, quantity int) ([]Document, error)
- func (b *BleveIndexer) Search(keywords string, page, resultsPerPage int) (result.Paginated[[]Document], error)
- func (b *BleveIndexer) SearchByAuthor(authorSlug string, page, resultsPerPage int) (result.Paginated[[]Document], error)
- func (b *BleveIndexer) Slug(document Document, batchSlugs map[string]struct{}) string
- type Document
- type Progress
Constants ¶
const ( TypeDocument = "document" TypeAuthor = "author" )
const Version = "v6"
Version identifies the mapping used for indexing. Any changes in the mapping requires an increase of version, to signal that a new index needs to be created.
Variables ¶
This section is empty.
Functions ¶
func CreateMapping ¶
func CreateMapping() mapping.IndexMapping
Types ¶
type Author ¶ added in v4.3.0
type Author struct {
Slug string
Name string
BirthName string
DataSourceID string
RetrievedOn time.Time
Type string
WikipediaLink map[string]string
InstanceOf float64
Description map[string]string
DateOfBirth precisiondate.PrecisionDate
DateOfDeath precisiondate.PrecisionDate
Website string
DataSourceImage string
Gender float64
Pseudonyms []string
}
func (Author) BirthNameIncludesName ¶ added in v4.7.0
func (Author) BleveType ¶ added in v4.3.0
BleveType is part of the bleve.Classifier interface and its purpose is to tell the indexer the type of the document, which will be used to decide which analyzer will parse it.
func (Author) YearOfBirthAbs ¶ added in v4.7.0
func (Author) YearOfDeathAbs ¶ added in v4.7.0
type BleveIndexer ¶
type BleveIndexer struct {
// contains filtered or unexported fields
}
func NewBleve ¶
func NewBleve(index bleve.Index, fs afero.Fs, libraryPath string, read map[string]metadata.Reader) *BleveIndexer
NewBleve creates a new BleveIndexer instance using the passed parameters
func (*BleveIndexer) AddFile ¶
func (b *BleveIndexer) AddFile(file string) (string, error)
AddFile adds a file to the index
func (*BleveIndexer) AddLibrary ¶
func (b *BleveIndexer) AddLibrary(batchSize int, forceIndexing bool) error
AddLibrary scans <libraryPath> for documents and adds them to the index in batches of <batchSize> if they haven't been previously indexed or if <forceIndexing> is true
func (*BleveIndexer) Author ¶ added in v4.3.0
func (b *BleveIndexer) Author(slug, lang string) (Author, error)
func (*BleveIndexer) Count ¶
func (b *BleveIndexer) Count(t string) (uint64, error)
Count returns the number of indexed documents
func (*BleveIndexer) Documents ¶
func (b *BleveIndexer) Documents(IDs []string) (map[string]Document, error)
func (*BleveIndexer) IndexAuthor ¶ added in v4.7.0
func (b *BleveIndexer) IndexAuthor(author Author) error
func (*BleveIndexer) IndexingProgress ¶
func (b *BleveIndexer) IndexingProgress() (Progress, error)
func (*BleveIndexer) RemoveFile ¶
func (b *BleveIndexer) RemoveFile(file string) error
RemoveFile removes a file from the index
func (*BleveIndexer) SameAuthors ¶
func (b *BleveIndexer) SameAuthors(slugID string, quantity int) ([]Document, error)
SameAuthors returns an array of metadata of documents by the same authors which does not belong to the same collection
func (*BleveIndexer) SameSeries ¶
func (b *BleveIndexer) SameSeries(slugID string, quantity int) ([]Document, error)
SameSeries returns an array of metadata of documents in the same series
func (*BleveIndexer) SameSubjects ¶
func (b *BleveIndexer) SameSubjects(slugID string, quantity int) ([]Document, error)
SameSubjects returns an array of metadata of documents by other authors, different between each other, which have similar subjects as the passed one and does not belong to the same collection
func (*BleveIndexer) Search ¶
func (b *BleveIndexer) Search(keywords string, page, resultsPerPage int) (result.Paginated[[]Document], error)
Search look for documents which match with the passed keywords. Returns a maximum <resultsPerPage> documents, offset by <page>