indexer

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2015 License: Apache-2.0 Imports: 14 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

Endpoints returns a list of currently indexed endpoints.

func IndexObj

func IndexObj(object Indexable)

IndexObj processes and adds an object to the index.

func LoadIndex added in v0.3.0

func LoadIndex(idxFile string) error

LoadIndex loads index files from disk.

func ReIndex added in v0.3.3

func ReIndex(objects []Indexable) error

ReIndex rebuilds the search index from scratch

func SaveIndex added in v0.3.0

func SaveIndex(idxFile string) error

SaveIndex saves the index files to disk.

func SearchIndex

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

SearchIndex searches 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)

SearchRange performs a range search on the given index.

func SearchResults added in v0.9.1

func SearchResults(term string, notop bool, docs map[string]*IdxDoc) (map[string]*IdxDoc, error)

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

func SearchResultsRange added in v0.9.1

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

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

func SearchResultsText added in v0.9.1

func SearchResultsText(term string, notop bool, docs map[string]*IdxDoc) (map[string]*IdxDoc, error)

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

func SearchText

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

SearchText performs a full-ish text search of the index.

Types

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 struct {
	// contains filtered or unexported fields
}

Index 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
}

Indexable is an 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