Documentation
¶
Index ¶
- Constants
- Variables
- type Base
- type Bookmark
- type BookmarkIndexable
- type Client
- func (c *Client) Alias(indexName string, aliasName string) (bool, error)
- func (c *Client) AliasNames() ([]string, error)
- func (c *Client) Aliases() ([]string, error)
- func (c *Client) Default(indexName string) (bool, error)
- func (c *Client) Delete(indexName string)
- func (c *Client) Doctor()
- func (c *Client) Health() (*elastic.ClusterHealthResponse, error)
- func (c *Client) Index(x *Root) (bool, error)
- func (c *Client) IndexNames() ([]string, error)
- func (c *Client) Indices() ([]string, error)
- func (c *Client) Mappings() (map[string]interface{}, error)
- func (c *Client) Parse(b []byte) (*Root, error)
- func (c *Client) Search(term string) (*elastic.SearchResult, error)
- func (c *Client) Suggest(term string) (elastic.SuggestResult, error)
- func (c *Client) URL() string
- func (c *Client) Unalias(aliasName string) (bool, error)
- func (c *Client) Version() string
- type ClientOptionFunc
- type CountResult
- type Meta
- type MetaIndexable
- type NameSuggest
- type Root
- type Roots
Constants ¶
const ( // DefaultRemote decides if the ES cluster is on Bonsai.io or it's local DefaultRemote = false // DefaultURL is the default ES local address DefaultURL = "http://127.0.0.1:9200" // DefaultVerbose decides if you wanna be bored by some noisy logs DefaultVerbose = false )
const DefaultAliasName = "elasticbookdefault"
DefaultAliasName is the Elasticsearch alias used in Searches
const DefaultIndexName = "elasticbook"
DefaultIndexName is the Elasticsearch index
const TypeName = "bookmark"
TypeName is the type used
Variables ¶
var DefaultFields = []string{"name", "url"}
DefaultFields is where to look when looking for bookmarks
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct {
Children []Bookmark `json:"children"`
DateAdded string `json:"date_added"`
DataModified string `json:"date_modified"`
ID string `json:"id"`
Name string `json:"name"`
NodeType string `json:"type"`
}
Base is a "folder-like" container of Bookmarks
type Bookmark ¶
type Bookmark struct {
DateAdded string `json:"date_added"`
OriginalID string `json:"id"`
MetaInfo Meta `json:"meta_info,omitempty"`
Name string `json:"name"`
SyncTransactionVersion string `json:"sync_transaction_version"`
Type string `json:"type"`
URL string `json:"url"`
}
Bookmark is a bookmark entry
type BookmarkIndexable ¶
type BookmarkIndexable struct {
DateAdded time.Time `json:"date_added"`
OriginalID string `json:"id"`
MetaInfo MetaIndexable `json:"meta_info,omitempty"`
Name string `json:"name"`
NameSuggest NameSuggest `json:"name_suggest"`
SyncTransactionVersion string `json:"sync_transaction_version"`
Type string `json:"type"`
URL string `json:"url"`
}
BookmarkIndexable is a bookmark entry with a sanitised MetaInfo
.Suggest: NewSuggestField().
Input("Cycling is fun.").
Output("Cycling is a fun sport.")
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the ElasticBook wrapper to an Elastic Client The "elastic" package is really inspiring!
func ClientRemote ¶
ClientRemote connects to a remote ES cluster (Bonsai.io) Debug with this:
/_nodes/http?pretty=1
func NewClient ¶
func NewClient(options ...ClientOptionFunc) (*Client, error)
NewClient Set up the default client
func (*Client) Alias ¶
Alias creates an alias. It's enforced a constraint though: "No more than one index per alias" This means that, if the alias already exists, this method returns false.
func (*Client) AliasNames ¶
AliasNames returns the list of existing aliases (just the names, sorted). Due to the constraint enforced by Client#Alias this slice should not contains dupes (^_^)
func (*Client) Default ¶
Default switch the default alias to the given index name (if it exists). Returns true if the switch is successful.
func (*Client) Health ¶
func (c *Client) Health() (*elastic.ClusterHealthResponse, error)
Health check the status of the cluster
func (*Client) IndexNames ¶
IndexNames returns the list of existing indices (just the names)
func (*Client) Search ¶
func (c *Client) Search(term string) (*elastic.SearchResult, error)
Search is the API for searching
func (*Client) Suggest ¶
func (c *Client) Suggest(term string) (elastic.SuggestResult, error)
Suggest performs a _suggest query
type ClientOptionFunc ¶
ClientOptionFunc is a function that configures a Client. It is used in NewClient.
func SetElasticClient ¶
func SetElasticClient(elasticClient *elastic.Client) ClientOptionFunc
SetElasticClient decide which kind of elastic Client use (local or remote)
func SetURL ¶
func SetURL(u string) ClientOptionFunc
SetURL define the current URL used (just for convenience)
type CountResult ¶
type CountResult struct {
// contains filtered or unexported fields
}
CountResult contains the bookmarks counter
func (*CountResult) Add ¶
func (c *CountResult) Add(k string, v int)
Add a key value to the count container
func (*CountResult) String ¶
func (c *CountResult) String() string
func (*CountResult) Total ¶
func (c *CountResult) Total() int
Total return the grand total of Bookmark entries parsed/indexed
type Meta ¶
type Meta struct {
StarsID string `json:"stars.id"`
StarsImageData string `json:"stars.imageData"`
StarsIsSynced string `json:"stars.isSynced"`
StarsPageData string `json:"stars.pageData"`
StarsType string `json:"stars.type"`
}
Meta contains the attached metadata to the Bookmark entry
type MetaIndexable ¶
type MetaIndexable struct {
StarsID string `json:"stars_id"`
StarsImageData string `json:"stars_imageData"`
StarsIsSynced string `json:"stars_isSynced"`
StarsPageData string `json:"stars_pageData"`
StarsType string `json:"stars_type"`
}
MetaIndexable contains the attached metadata to the Bookmark entry w/o dots
type NameSuggest ¶
NameSuggest contains the input for the suggestion engine https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html Example:
POST /elasticbook-20160110174219/bookmark/_suggest?pretty
{
"name_suggest" : {
"text" : "Medium",
"completion" : {
"field" : "name_suggest"
}
}
}


