Documentation ¶
Overview ¶
The index package implements a distributed search index.
It is basically a simple reverse document index, implemented as a PartitionedService, which keeps the entire database in-memory (and occasionally checkpoints to disk).
The query engine is not particularly clever or efficient, and the query expression language is rudimental, but the implementation is very simple and straightforward. And, of course, the entire service can be replaced by anything that implements the Index interface.
Index ¶
- Variables
- func NewPartitionMapFromConfig() *partition.PartitionMap
- func RegisterService(is *IndexService)
- type AddDocRequest
- type DeleteDocRequest
- type DeleteDocResponse
- type Index
- type IndexClient
- type IndexService
- type IndexServiceRPC
- func (isrpc *IndexServiceRPC) AddDoc(req *AddDocRequest, resp *bool) error
- func (isrpc *IndexServiceRPC) DeleteDoc(req *DeleteDocRequest, resp *DeleteDocResponse) error
- func (isrpc *IndexServiceRPC) Scan(req *ScanRequest, resp *ScanResponse) error
- func (isrpc *IndexServiceRPC) Search(req *SearchRequest, resp *SearchResponse) error
- type MultiIndex
- func (is *MultiIndex) AddDoc(id api.SongID, doc api.Document) error
- func (is *MultiIndex) DeleteDoc(id api.SongID)
- func (is *MultiIndex) GetDocIds() []api.SongID
- func (is *MultiIndex) Lookup(key string, value string) api.SongSet
- func (is *MultiIndex) Save(path string) error
- func (is *MultiIndex) Scan(out chan api.SongID)
- func (is *MultiIndex) Search(query string) api.SongSet
- type QueryAstNode
- type QueryIndex
- type ScanRequest
- type ScanResponse
- type SearchRequest
- type SearchResponse
Constants ¶
This section is empty.
Variables ¶
var (
IndexPmapFile = config.String("index_pmap", "/etc/djrandom/part-index.json", "Index partition map file")
)
Functions ¶
func NewPartitionMapFromConfig ¶
func NewPartitionMapFromConfig() *partition.PartitionMap
func RegisterService ¶
func RegisterService(is *IndexService)
Types ¶
type DeleteDocRequest ¶
type DeleteDocResponse ¶
type DeleteDocResponse struct{}
type Index ¶
Index is an index for a single attribute. Each key can have multiple values.
type IndexClient ¶
type IndexClient struct { P *partition.PartitionMap // contains filtered or unexported fields }
IndexClient is the distributed index client stub.
func NewIndexClient ¶
func NewIndexClient(pmap *partition.PartitionMap) *IndexClient
func NewIndexClientFromConfig ¶
func NewIndexClientFromConfig() *IndexClient
func (*IndexClient) DeleteDoc ¶
func (ic *IndexClient) DeleteDoc(id api.SongID) error
DeleteDoc removes a document from the index, given its ID.
func (*IndexClient) Scan ¶
func (ic *IndexClient) Scan() []api.SongID
Scan returns a list of all the document IDs contained in the index (warning: potentially a very large list!).
type IndexService ¶
type IndexService struct { partition.PartitionedServiceBase // The in-memory multi-index object. Index *MultiIndex // Client for rebalancing. Client *IndexClient // contains filtered or unexported fields }
func NewIndexService ¶
func NewIndexService(stateFile string, pmap *partition.PartitionMap, selfTarget string) *IndexService
func (*IndexService) Move ¶
func (is *IndexService) Move(key string) error
func (*IndexService) Scan ¶
func (is *IndexService) Scan() <-chan string
func (*IndexService) Stop ¶
func (is *IndexService) Stop()
type IndexServiceRPC ¶
type IndexServiceRPC struct {
// contains filtered or unexported fields
}
Just a wrapper that only exposes RPC methods.
func (*IndexServiceRPC) AddDoc ¶
func (isrpc *IndexServiceRPC) AddDoc(req *AddDocRequest, resp *bool) error
func (*IndexServiceRPC) DeleteDoc ¶
func (isrpc *IndexServiceRPC) DeleteDoc(req *DeleteDocRequest, resp *DeleteDocResponse) error
func (*IndexServiceRPC) Scan ¶
func (isrpc *IndexServiceRPC) Scan(req *ScanRequest, resp *ScanResponse) error
func (*IndexServiceRPC) Search ¶
func (isrpc *IndexServiceRPC) Search(req *SearchRequest, resp *SearchResponse) error
type MultiIndex ¶
type MultiIndex struct { // The various indexes we built. Indexes map[string]*Index // The reverse docId -> values map which we're going to use to // remove documents from the index. D map[api.SongID]api.Document // contains filtered or unexported fields }
func LoadMultiIndex ¶
func LoadMultiIndex(path string) (*MultiIndex, error)
func NewMultiIndex ¶
func NewMultiIndex() *MultiIndex
func (*MultiIndex) DeleteDoc ¶
func (is *MultiIndex) DeleteDoc(id api.SongID)
DeleteDoc removes a document from the index.
func (*MultiIndex) GetDocIds ¶
func (is *MultiIndex) GetDocIds() []api.SongID
GetDocIds returns the list of unique document IDs in the index.
func (*MultiIndex) Lookup ¶
func (is *MultiIndex) Lookup(key string, value string) api.SongSet
Lookup performs a point lookup in the index, returns a list of document IDs.
func (*MultiIndex) Save ¶
func (is *MultiIndex) Save(path string) error
func (*MultiIndex) Scan ¶
func (is *MultiIndex) Scan(out chan api.SongID)
Scan outputs all document IDs to the given channel.
type QueryAstNode ¶
type QueryAstNode interface { Eval(QueryIndex) api.SongSet String() string }
Query AST.
func NewQueryAndNode ¶
func NewQueryAndNode(args []QueryAstNode) QueryAstNode
func NewQueryOrNode ¶
func NewQueryOrNode(args []QueryAstNode) QueryAstNode
func NewQuerySearchNode ¶
func NewQuerySearchNode(key string, value string) QueryAstNode
func NewQuerySearchNodeOnManyKeys ¶
func NewQuerySearchNodeOnManyKeys(keys []string, value string) QueryAstNode
func StringToQuery ¶
func StringToQuery(s string) QueryAstNode
StringToQuery parses a query string and builds a search query.
type QueryIndex ¶
Interface from the index implementation to the query engine.
type ScanRequest ¶
type ScanRequest struct{}
type ScanResponse ¶
type SearchRequest ¶
type SearchRequest struct {
Query string
}