fts

package
v0.0.0-...-11a7b2c Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

The functions in this file were taken from https://github.com/akrylysov/simplefts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	Id   string `json:"id,omitempty"`
	Path string `json:"path"`
}

func (*Document) Json

func (d *Document) Json() (interface{}, error)

Json returns a json encoded Document

type DocumentJson

type DocumentJson struct {
	Id       string      `json:"id"`
	Document interface{} `json:"document"`
}

type Index

type Index struct {
	Id               string              `json:"id"`
	SearchProperties []string            `json:"searchProperties"`
	Documents        []Document          `json:"documents,omitempty"`
	InvertedIndex    map[string][]string `json:"-"`
	// contains filtered or unexported fields
}

Index struct

func MakeIndex

func MakeIndex(name string, searchProperties []string) Index

MakeIndex initializes and Index

func (*Index) AddDocument

func (i *Index) AddDocument(id string, doc map[string]interface{}) (string, error)

AddDocument adds a document to the index

func (*Index) Build

func (i *Index) Build() error

Build builds the index

func (*Index) DeleteDocument

func (i *Index) DeleteDocument(documentId string)

DeleteDocument deletes a document from the index

func (*Index) Destroy

func (i *Index) Destroy()

Destroy destroys the data assoicated with the index

func (*Index) GetDocument

func (i *Index) GetDocument(documentId string) (Document, bool)

GetDocument gets a document from the index.

func (*Index) ReplaceDocument

func (i *Index) ReplaceDocument(document DocumentJson)

Replace document replaces a document in an index.

func (*Index) SearchValue

func (i *Index) SearchValue(value string) []string

func (*Index) Validate

func (i *Index) Validate() error

type IndexManager

type IndexManager struct {
	Path    string            `json:"-"`
	Indexes map[string]*Index `json:"indexes"`
	Cache   *cache.Cache      `json:"-"`
	// contains filtered or unexported fields
}

func NewIndexManager

func NewIndexManager(path string, cache *cache.Cache) *IndexManager

NewIndexManager creates a new index manager object

func (*IndexManager) AddIndex

func (indexManager *IndexManager) AddIndex(index *Index) error

AddIndex adds an index

func (*IndexManager) DeleteIndex

func (indexManager *IndexManager) DeleteIndex(indexId string) error

DeleteIndex deletes an index

func (*IndexManager) GetIndex

func (indexManager *IndexManager) GetIndex(indexId string) (*Index, bool)

GetIndex returns an index

func (*IndexManager) Save

func (indexManager *IndexManager) Save() error

Save saves the indexes to persistent storage

Jump to

Keyboard shortcuts

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