Documentation
¶
Index ¶
- func DefaultCollectionOpener(ctx context.Context, opt Option) (*docstore.Collection, error)
- func DefaultCollectionURL(opt ...Option) (string, error)
- type CombinedError
- type Document
- type Option
- 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) 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)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 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
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
watertower-server
command
|
|
|
samples
|
|
|
httpstatus
command
|
|
|
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 |
`