indexer

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2014 License: Apache-2.0 Imports: 13 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()

Clear index of all collections and documents

func CreateNewCollection

func CreateNewCollection(idxName string)

Create 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

Delete a collection from the index. Useful only for data bags.

func DeleteItemFromCollection

func DeleteItemFromCollection(idxName string, doc string) error

Delete an item from a collection

func Endpoints

func Endpoints() []string

Return a list of currently indexed endpoints

func IndexObj

func IndexObj(object Indexable)

Process and add an object to the index.

func LoadIndex added in v0.3.0

func LoadIndex(idxFile string) error

Load index files from disk.

func ReIndex added in v0.3.3

func ReIndex(objects []Indexable) error

Rebuild the search index from scratch

func SaveIndex added in v0.3.0

func SaveIndex(idxFile string) error

Save the index files to disk.

func SearchIndex

func SearchIndex(idxName string, term string, notop bool) (map[string]*IdxDoc, error)

Search for a string in the given index. Returns a slice of names of matching objects, or an error on failure.

func SearchRange

func SearchRange(idxName string, field string, start string, end string, inclusive bool) (map[string]*IdxDoc, error)

Perform a range search on the given index.

func SearchText

func SearchText(idxName string, term string, notop bool) (map[string]*IdxDoc, error)

Perform a full-ish text search of the index.

Types

type IdxCollection

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

Holds a map of documents.

func (*IdxCollection) GobDecode added in v0.3.0

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

func (*IdxCollection) GobEncode added in v0.3.0

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

type IdxDoc

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

The indexed documents that are actually searched.

func (*IdxDoc) Examine

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

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 (i *IdxDoc) GobDecode(buf []byte) error

func (*IdxDoc) GobEncode added in v0.3.0

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

func (*IdxDoc) RangeSearch

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

Searches for a range of values.

func (*IdxDoc) TextSearch

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

Perform a text search of an index document.

type Index

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

Holds a map of document collections.

func (*Index) GobDecode added in v0.3.0

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

func (*Index) GobEncode added in v0.3.0

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

type Indexable

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

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

Jump to

Keyboard shortcuts

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