indexer

package
v0.11.4-pre2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package indexer indexes objects that implement the Indexable interface. The index is all in memory right now, but it can be frozen and saved to disk for persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearIndex added in v0.3.3

func ClearIndex()

ClearIndex of all collections and documents

func CreateNewCollection

func CreateNewCollection(idxName string)

CreateNewCollection creates an index for data bags when they are created, rather than when the first data bag item is uploaded

func DeleteCollection

func DeleteCollection(idxName string) error

DeleteCollection deletes a collection from the index. Useful only for data bags.

func DeleteItemFromCollection

func DeleteItemFromCollection(idxName string, doc string) error

DeleteItemFromCollection deletes an item from a collection

func Endpoints

func Endpoints() ([]string, error)

Endpoints returns a list of currently indexed endpoints.

func IndexObj

func IndexObj(object Indexable)

IndexObj processes and adds an object to the index.

func Initialize added in v0.10.0

func Initialize(config *config.Conf)

func LoadIndex added in v0.3.0

func LoadIndex() error

LoadIndex loads index files from disk.

func ReIndex added in v0.3.3

func ReIndex(objects []Indexable, rCh chan struct{}) error

ReIndex rebuilds the search index from scratch

func SaveIndex added in v0.3.0

func SaveIndex() error

SaveIndex saves the index files to disk.

Types

type Document added in v0.10.0

type Document interface {
}

type FileIndex added in v0.10.0

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

func (*FileIndex) Clear added in v0.10.0

func (i *FileIndex) Clear() error

func (*FileIndex) CreateCollection added in v0.10.0

func (i *FileIndex) CreateCollection(idxName string) error

func (*FileIndex) CreateNewCollection added in v0.10.1

func (i *FileIndex) CreateNewCollection(idxName string) error

func (*FileIndex) DeleteCollection added in v0.10.0

func (i *FileIndex) DeleteCollection(idxName string) error

func (*FileIndex) DeleteItem added in v0.10.0

func (i *FileIndex) DeleteItem(idxName string, doc string) error

func (*FileIndex) Endpoints added in v0.10.0

func (i *FileIndex) Endpoints() ([]string, error)

Endpoints returns a list of currently indexed endpoints.

func (*FileIndex) GobDecode added in v0.10.0

func (i *FileIndex) GobDecode(buf []byte) error

func (*FileIndex) GobEncode added in v0.10.0

func (i *FileIndex) GobEncode() ([]byte, error)

func (*FileIndex) Initialize added in v0.10.0

func (i *FileIndex) Initialize() error

func (*FileIndex) Load added in v0.10.0

func (i *FileIndex) Load() error

func (*FileIndex) Save added in v0.10.0

func (i *FileIndex) Save() error

func (*FileIndex) SaveItem added in v0.10.0

func (i *FileIndex) SaveItem(object Indexable) error

func (*FileIndex) Search added in v0.10.0

func (i *FileIndex) Search(idx string, term string, notop bool) (map[string]Document, error)

func (*FileIndex) SearchRange added in v0.10.0

func (i *FileIndex) SearchRange(idx string, field string, start string, end string, inclusive bool) (map[string]Document, error)

func (*FileIndex) SearchResults added in v0.10.0

func (i *FileIndex) SearchResults(term string, notop bool, docs map[string]Document) (map[string]Document, error)

SearchResults does a basic search from an existing collection of documents, rather than the full index.

func (*FileIndex) SearchResultsRange added in v0.10.0

func (i *FileIndex) SearchResultsRange(field string, start string, end string, inclusive bool, docs map[string]Document) (map[string]Document, error)

SearchResultsRange does a range search on a collection of search results, rather than the full index.

func (*FileIndex) SearchResultsText added in v0.10.0

func (i *FileIndex) SearchResultsText(term string, notop bool, docs map[string]Document) (map[string]Document, error)

SearchResultsText does a text searc on a collection of search results, rather than the full index.

func (*FileIndex) SearchText added in v0.10.0

func (i *FileIndex) SearchText(idx string, term string, notop bool) (map[string]Document, error)

type IdxCollection

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

IdxCollection holds a map of documents.

func (*IdxCollection) GobDecode added in v0.3.0

func (ic *IdxCollection) GobDecode(buf []byte) error

func (*IdxCollection) GobEncode added in v0.3.0

func (ic *IdxCollection) GobEncode() ([]byte, error)

type IdxDoc

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

IdxDoc is the indexed documents that are actually searched.

func (*IdxDoc) Examine

func (idoc *IdxDoc) Examine(term string) (bool, error)

Examine searches a document, determining if it needs to do a search for an exact term or a regexp search.

func (*IdxDoc) GobDecode added in v0.3.0

func (idoc *IdxDoc) GobDecode(buf []byte) error

func (*IdxDoc) GobEncode added in v0.3.0

func (idoc *IdxDoc) GobEncode() ([]byte, error)

func (*IdxDoc) RangeSearch

func (idoc *IdxDoc) RangeSearch(field string, start string, end string, inclusive bool) (bool, error)

RangeSearch searches for a range of values.

func (*IdxDoc) TextSearch

func (idoc *IdxDoc) TextSearch(term string) (bool, error)

TextSearch performs a text search of an index document.

type Index

type Index interface {
	Search(string, string, bool) (map[string]Document, error)
	SearchText(string, string, bool) (map[string]Document, error)
	SearchRange(string, string, string, string, bool) (map[string]Document, error)
	SearchResults(string, bool, map[string]Document) (map[string]Document, error)
	SearchResultsRange(string, string, string, bool, map[string]Document) (map[string]Document, error)
	SearchResultsText(string, bool, map[string]Document) (map[string]Document, error)
	Save() error
	Load() error
	ObjIndexer
}

Index holds a map of document collections.

func GetIndex added in v0.10.0

func GetIndex() Index

type IndexCollection added in v0.10.0

type IndexCollection interface {
	// contains filtered or unexported methods
}

type Indexable

type Indexable interface {
	DocID() string
	Index() string
	Flatten() map[string]interface{}
}

Indexable is an interface that provides all the information necessary to index an object. All objects that will be indexed need to implement this.

type ObjIndexer added in v0.10.0

type ObjIndexer interface {
	Initialize() error
	CreateCollection(string) error
	CreateNewCollection(string) error
	DeleteCollection(string) error
	DeleteItem(string, string) error
	SaveItem(Indexable) error
	Endpoints() ([]string, error)
	Clear() error
}

type PostgresIndex added in v0.10.0

type PostgresIndex struct {
}

func (*PostgresIndex) Clear added in v0.10.0

func (p *PostgresIndex) Clear() error

func (*PostgresIndex) CreateCollection added in v0.10.0

func (p *PostgresIndex) CreateCollection(col string) error

func (*PostgresIndex) CreateNewCollection added in v0.10.1

func (p *PostgresIndex) CreateNewCollection(col string) error

func (*PostgresIndex) DeleteCollection added in v0.10.0

func (p *PostgresIndex) DeleteCollection(col string) error

func (*PostgresIndex) DeleteItem added in v0.10.0

func (p *PostgresIndex) DeleteItem(idxName string, doc string) error

func (*PostgresIndex) Endpoints added in v0.10.0

func (p *PostgresIndex) Endpoints() ([]string, error)

func (*PostgresIndex) Initialize added in v0.10.0

func (p *PostgresIndex) Initialize() error

func (*PostgresIndex) SaveItem added in v0.10.0

func (p *PostgresIndex) SaveItem(obj Indexable) error

Jump to

Keyboard shortcuts

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