search

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuggestionTypeMetadata = "metadata"
	SuggestionTypeOperand  = "operand"
	SuggestionTypeKey      = "key"
)
View Source
const MaxSuggestMetadata = 10

max for either metadate keys or values

View Source
const MaxSuggestions = 50

total maximum for suggestions

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentFilter

type DocumentFilter struct {
	Query    string    `json:"q"`
	Tag      string    `json:"tag"`
	After    time.Time `json:"after"`
	Before   time.Time `json:"before"`
	Metadata string    `json:"metadata"`
	Sort     string    `json:"sort"`
	SortMode string    `json:"sort_mode"`
	Favorite bool      `json:"favorite"`
}

DocumentFilter defines filter for searching/filtering documents

type Engine

type Engine struct {
	Url    string
	ApiKey string
	// contains filtered or unexported fields
}

Engine is as search engine that uses Meilisearch to provide full-text-search across documents.

func NewEngine

func NewEngine(db *storage.Database, conf *config.Meilisearch) (*Engine, error)

func (*Engine) AddIndex added in v0.6.0

func (e *Engine) AddIndex() error

func (*Engine) DeleteDocument

func (e *Engine) DeleteDocument(docId string, userId int) error

func (*Engine) DeleteDocuments

func (e *Engine) DeleteDocuments(userId int) error

func (*Engine) GetHealth

func (e *Engine) GetHealth() (string, bool, error)

func (*Engine) GetIndexStatus added in v0.6.0

func (e *Engine) GetIndexStatus() (IndexStatus, error)

func (*Engine) GetStatus

func (e *Engine) GetStatus() (*EngineStatus, error)

func (*Engine) IndexDocuments

func (e *Engine) IndexDocuments(docs *[]models.Document, userId int) error

IndexDocuments sends documents to meilisearch for indexing

func (*Engine) SearchDocuments

func (e *Engine) SearchDocuments(userId int, query string, sort storage.SortKey, paging storage.Paging) ([]*models.Document, int, error)

SearchDocuments searches documents for given user. Query can be anything. If field="", search in any field, else search only specified field

func (*Engine) SuggestSearch

func (e *Engine) SuggestSearch(userId int, query string) (*QuerySuggestions, error)

type EngineStatus

type EngineStatus struct {
	Ok      bool   `json:"engine_ok"`
	Status  string `json:"status"`
	Version string `json:"version"`
	Name    string `json:"name"`
}

type IndexStatus added in v0.6.0

type IndexStatus struct {
	NumDocuments int  `json:"documents_count"`
	Indexing     bool `json:"indexing"`
}

type QuerySuggestions

type QuerySuggestions struct {
	Suggestions []Suggestion `json:"suggestions"`
	Prefix      string       `json:"prefix"`
	ValidQuery  bool         `json:"valid_query"`
}

QuerySuggestions contains the current normalized query and suggestions. Concatenating the prefix with any suggestion results in valid query. e.g. query 'some data' results in prefix 'some' and suggestion: ['metadata:', 'datavalue:']

type Suggestion

type Suggestion struct {
	Value string `json:"value"`
	Type  string `json:"type"`
	Hint  string `json:"hint"`
}

Jump to

Keyboard shortcuts

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