Documentation ¶
Index ¶
- Variables
- func DefaultCollectionOpener(ctx context.Context, opt Option) (*docstore.Collection, error)
- func DefaultCollectionURL(opt ...Option) (string, error)
- type CombinedError
- type Document
- type Option
- type Storage
- type WaterTower
- func (wt *WaterTower) AddTagToDocument(tag, uniqueKey string) error
- func (wt *WaterTower) Close() (err error)
- func (wt *WaterTower) FindDocumentByKey(uniqueKey string) (*Document, error)
- func (wt *WaterTower) FindDocuments(ids ...uint32) ([]*Document, error)
- func (wt *WaterTower) FindTags(tagNames ...string) ([]*tag, error)
- func (wt *WaterTower) FindTagsWithContext(ctx context.Context, tagNames ...string) ([]*tag, error)
- func (wt *WaterTower) FindTokens(words ...string) ([]*token, error)
- func (wt *WaterTower) FindTokensWithContext(ctx context.Context, words ...string) ([]*token, error)
- func (wt *WaterTower) PostDocument(uniqueKey string, document *Document) (uint32, error)
- func (wt *WaterTower) ReadIndex(w io.Reader) error
- func (wt *WaterTower) RemoveDocumentByID(docID uint32) error
- func (wt *WaterTower) RemoveDocumentByKey(uniqueKey string) error
- func (wt *WaterTower) RemoveDocumentFromTag(tag string, docID uint32) error
- func (wt *WaterTower) Search(searchWord string, tags []string, lang string) ([]*Document, error)
- func (wt *WaterTower) WriteIndex(w io.Writer) error
Constants ¶
This section is empty.
Variables ¶
var ErrBatchGet = errors.New("batch get error")
Functions ¶
func DefaultCollectionOpener ¶
func DefaultCollectionURL ¶
DefaultCollectionURL returns collection URL. This function is for help message or debugging
Types ¶
type CombinedError ¶
func (CombinedError) Error ¶
func (c CombinedError) Error() string
type Document ¶
type Document struct { ID string `json:"-" docstore:"id"` UniqueKey string `json:"unique_key" docstore:"unique_key"` Language string `json:"lang" docstore:"lang"` Title string `json:"title" docstore:"title"` UpdatedAt time.Time `json:"updated_at,omitempty" docstore:"updated_at"` Tags []string `json:"tags,omitempty" docstore:"tags"` Content string `json:"content" docstore:"content"` WordCount int `json:"-" docstore:"wc"` Metadata map[string]string `json:"metadata,omitempty" docstore:"metadata"` TitleWordCount int `json:"-" docstore:"twc"` Score float64 `json:"score,omitempty" docstore:"-"` Schema string `json:"$schema,omitempty" docstore:"-"` Comment string `json:"$comment,omitempty" docstore:"-"` }
func (Document) DocumentID ¶
type Storage ¶ added in v0.1.1
type Storage interface { IncrementDocID() (int, error) IncrementDocCount() (int, error) DecrementDocCount() error DocCount() (int, error) Context() context.Context Create(id string, doc interface{}) error Replace(id string, doc interface{}) error GetDoc(doc *Document) error GetDocKey(docKey *documentKey) error GetTag(tag *tagEntity) error GetToken(token *tokenEntity) error BatchDocGet(ctx context.Context, docs []*Document) (map[int]bool, error) BatchTagGet(ctx context.Context, tags []*tagEntity) (map[int]bool, error) BatchTokenGet(ctx context.Context, tokens []*tokenEntity) (map[int]bool, error) DeleteDoc(doc *Document) error DeleteDocKey(docKey *documentKey) error DeleteTag(tag *tagEntity) error DeleteToken(token *tokenEntity) error Close() error WriteIndex(w io.Writer) error ReadIndex(r io.Reader) error }
type WaterTower ¶
type WaterTower struct {
// contains filtered or unexported fields
}
func NewWaterTower ¶
func NewWaterTower(ctx context.Context, opt ...Option) (*WaterTower, error)
NewWaterTower initialize WaterTower instance
func (*WaterTower) AddTagToDocument ¶
func (wt *WaterTower) AddTagToDocument(tag, uniqueKey string) error
AddTagToDocument adds tag to existing document.
func (*WaterTower) Close ¶
func (wt *WaterTower) Close() (err error)
Close closes document store connection. Some docstore (at least memdocstore) needs Close() to store file
func (*WaterTower) FindDocumentByKey ¶
func (wt *WaterTower) FindDocumentByKey(uniqueKey string) (*Document, error)
FindDocumentByKey looks up document by uniqueKey.
func (*WaterTower) FindDocuments ¶
func (wt *WaterTower) FindDocuments(ids ...uint32) ([]*Document, error)
FindDocuments returns documents by id list.
func (*WaterTower) FindTags ¶
func (wt *WaterTower) FindTags(tagNames ...string) ([]*tag, error)
func (*WaterTower) FindTagsWithContext ¶
func (wt *WaterTower) FindTagsWithContext(ctx context.Context, tagNames ...string) ([]*tag, error)
func (*WaterTower) FindTokens ¶
func (wt *WaterTower) FindTokens(words ...string) ([]*token, error)
func (*WaterTower) FindTokensWithContext ¶
func (wt *WaterTower) FindTokensWithContext(ctx context.Context, words ...string) ([]*token, error)
func (*WaterTower) PostDocument ¶
func (wt *WaterTower) PostDocument(uniqueKey string, document *Document) (uint32, error)
PostDocument registers single document to storage and update index
uniqueKey is a key of document like URL.
document's title and content fields are indexed and searched via natural language algorithms (tokenize, stemming).
document's tags field contains texts and filter documents via complete match algorithm.
func (*WaterTower) RemoveDocumentByID ¶
func (wt *WaterTower) RemoveDocumentByID(docID uint32) error
RemoveDocumentByID removes document via ID
func (*WaterTower) RemoveDocumentByKey ¶
func (wt *WaterTower) RemoveDocumentByKey(uniqueKey string) error
RemoveDocumentByKey removes document via uniqueKey
func (*WaterTower) RemoveDocumentFromTag ¶
func (wt *WaterTower) RemoveDocumentFromTag(tag string, docID uint32) error
func (*WaterTower) Search ¶
Search searches documents.
searchWord is for title, content. This is processed by NLP logic specified by lang parameter.
tags is for filter search result.
func (*WaterTower) WriteIndex ¶ added in v0.1.1
func (wt *WaterTower) WriteIndex(w io.Writer) error
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
samples
|
|
webapi
|
|
restapi
Package restapi watertower Schemes: http Host: localhost:3000 BasePath: / Version: 1.0 Consumes: - application/json Produces: - application/json swagger:meta
|
Package restapi watertower Schemes: http Host: localhost:3000 BasePath: / Version: 1.0 Consumes: - application/json Produces: - application/json swagger:meta |