Documentation ¶
Overview ¶
package sdk provides the elasthink SDK which allows you to run all elasthink's core functionality in your service
Index ¶
- type CreateIndexSpec
- type ElasthinkSDK
- func (es *ElasthinkSDK) CreateIndex(spec CreateIndexSpec) (bool, error)
- func (es *ElasthinkSDK) GetKeywordSuggestion(spec GetKeywordSuggestionSpec) ([]string, error)
- func (es *ElasthinkSDK) Search(spec SearchSpec) (SearchResult, error)
- func (es *ElasthinkSDK) UpdateIndex(spec UpdateIndexSpec) (bool, error)
- type GetKeywordSuggestionSpec
- type InitializeSpec
- type RankByShowCount
- type RedisConfig
- type SdkConfig
- type SearchResult
- type SearchResultRankData
- type SearchSpec
- type UpdateIndexSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateIndexSpec ¶
CreateIndexSpec is the spec of CreateIndex function DocumentType is the type of the document DocumentName is the name of the document DocumentID is the id of the document
type ElasthinkSDK ¶
ElasthinkSDK is the main struct of elasthink SDK, initialized using initalize function
func Initialize ¶
func Initialize(initializeSpec InitializeSpec) ElasthinkSDK
Initialize is the function that return ElasthinkSDK
func (*ElasthinkSDK) CreateIndex ¶
func (es *ElasthinkSDK) CreateIndex(spec CreateIndexSpec) (bool, error)
CreateIndex is a function to create new index based on documentType, documentID, and document name documentType is the type of the document, to categorize documents. For example: campaign documentID, is the ID of document, the key of document. For example: 1 documentName, is the name of documennt, the value which will be indexed. For example: "we want to eat seafood on a restaurant"
func (*ElasthinkSDK) GetKeywordSuggestion ¶
func (es *ElasthinkSDK) GetKeywordSuggestion(spec GetKeywordSuggestionSpec) ([]string, error)
GetKeywordSuggestion is the core function to get keyword suggestion from a given keyword prefix and document type
func (*ElasthinkSDK) Search ¶
func (es *ElasthinkSDK) Search(spec SearchSpec) (SearchResult, error)
Search is the core function of searching a document
func (*ElasthinkSDK) UpdateIndex ¶
func (es *ElasthinkSDK) UpdateIndex(spec UpdateIndexSpec) (bool, error)
UpdateIndex is function to update previously created index
type GetKeywordSuggestionSpec ¶
GetKeywordSuggestionSpec is the spec of Getting Keyword Suggestion function
type InitializeSpec ¶
type InitializeSpec struct { RedisConfig RedisConfig SdkConfig SdkConfig }
InitializeSpec is the payload to initialize Elasthink SDK
type RankByShowCount ¶
type RankByShowCount []SearchResultRankData
RankByShowCount is the additional struct for document ranking purpose based on its ShowCount
func (RankByShowCount) Len ¶
func (r RankByShowCount) Len() int
Len overrides Len function of RankByShowCount
func (RankByShowCount) Less ¶
func (r RankByShowCount) Less(i, j int) bool
Less overrides Less function of RankByShowCount
func (RankByShowCount) Swap ¶
func (r RankByShowCount) Swap(i, j int)
Swap overrides Swap function of RankByShowCount
type RedisConfig ¶
RedisConfig is the basic configuration to initialize a redis connection Address is the address of the redis will be used, for localhost with port 6379 (default redis port), just use "localhost:6379" MaxActive is the maximum of access to the redis, example value is 30 MaxIdle is the maximum idle access to the redis, example value is 10 Timeout is the timeout of accessing redis (in second), example value is 10
type SdkConfig ¶
type SdkConfig struct { IsUsingStopWordsRemoval bool StopWordRemovalData []string AvailableDocumentType []string }
SdkConfig is the configuration to initialize Elasthink SDK IsUsingStopWordsRemoval enables Elasthink to remove stop words StopWordRemovalData define the stop words AvailableDocumentType the document type available, for example "campaign"
type SearchResult ¶
type SearchResult struct {
RankedResultList RankByShowCount
}
SearchResult is the result of Search, it have array of search result datum
type SearchResultRankData ¶
SearchResultRankData is the search result datum
type SearchSpec ¶
SearchSpec is the spec of Search function
type UpdateIndexSpec ¶
type UpdateIndexSpec struct { DocumentType string OldDocumentName string NewDocumentName string DocumentID int64 }
UpdateIndexSpec is the spec of UpdateIndex function OldDocumentName is the name of the old document which will be replaced by new document NewDocumentName is the name of the new document DocumentID is the id of the document