index

package
v3.13.4 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package index provides interfaces for indexing edocuments metadata and retrieving this metadata back from the index. Currently, there is only one implementation to those interfaces, using Bleve.

Index

Constants

View Source
const Version = "v2"

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 Create added in v3.12.0

func Create(path string) bleve.Index

func CreateMapping added in v3.12.0

func CreateMapping() mapping.IndexMapping

Types

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) error

AddFile adds a file to the index

func (*BleveIndexer) AddLibrary

func (b *BleveIndexer) AddLibrary(batchSize int) error

AddLibrary scans <libraryPath> for documents and adds them to the index in batches of <bathSize>

func (*BleveIndexer) Close

func (b *BleveIndexer) Close() error

Close closes the index

func (*BleveIndexer) Count

func (b *BleveIndexer) Count() (uint64, error)

Count returns the number of indexed documents

func (*BleveIndexer) Document

func (b *BleveIndexer) Document(slug string) (Document, error)

func (*BleveIndexer) Documents added in v3.8.0

func (b *BleveIndexer) Documents(IDs []string) (map[string]Document, error)

func (*BleveIndexer) ID added in v3.6.0

func (b *BleveIndexer) ID(meta DocumentWrite, file string) string

func (*BleveIndexer) IndexingProgress added in v3.12.0

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 added in v3.5.0

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 added in v3.5.0

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 added in v3.5.0

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>

func (*BleveIndexer) Slug added in v3.6.0

func (b *BleveIndexer) Slug(document DocumentWrite, batchSlugs map[string]struct{}) string

As Bleve index is not updated until the batch is executed, we need to store the slugs processed in the current batch in memory to also compare the current doc slug against them.

type Document added in v3.6.0

type Document struct {
	metadata.Metadata
	ID          string
	Slug        string
	Highlighted bool
}

type DocumentWrite added in v3.6.0

type DocumentWrite struct {
	Document
	AuthorsEq  []string
	SeriesEq   string
	SubjectsEq []string
}

DocumentWrite is an extension to Document that is used only when writing to the index, as some of its fields are only used to perform searches and not returned

func (DocumentWrite) BleveType added in v3.10.0

func (d DocumentWrite) BleveType() string

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.

type Progress added in v3.12.0

type Progress struct {
	RemainingTime time.Duration
	Percentage    float64
}

Jump to

Keyboard shortcuts

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