Documentation
¶
Index ¶
- Constants
- Variables
- func AddEventPrefix(key string) string
- func ApplyCustomEventsEs7(query *es7.BoolQuery, filters map[string]interface{})
- func FetchDocumentForSource(index string, documentId string) (map[string]interface{}, error)
- func GenerateRecentDocId(documentId, index string) string
- func GetAnalyticsIndex() string
- func GetCustomFilters(values url.Values) map[string]interface{}
- func GetDocumentSuggestionsIndex() string
- func HasSearchTypeOfQuery(rsRequestBody *querytranslate.RSQuery) bool
- func IsAnalyticsEnabled() bool
- func IsPreDefinedTermFilter(e string) bool
- func Recorder() middleware.Middleware
- func SetPreferencesInCache(a AnalyticsPreferences)
- type ActiveUserSession
- type ActiveUserSessionES
- type ActiveUserSessionItem
- type ActiveUserSessionTTLMap
- type Analytics
- func (a *Analytics) AlternateRoutes() []plugins.Route
- func (a *Analytics) ESMiddleware() []middleware.Middleware
- func (a *Analytics) InitFunc() error
- func (a *Analytics) Name() string
- func (a *Analytics) RSMiddleware() []middleware.Middleware
- func (a *Analytics) RecordAnalytics(request rules.ScriptRequest, rsRequestBody *querytranslate.RSQuery, ...) (*string, rules.ScriptResponse)
- func (a *Analytics) RecordClick(r *http.Request, body ClickRecord) rules.ScriptResponse
- func (a *Analytics) RecordConversion(r *http.Request, body ConversionRecord) rules.ScriptResponse
- func (a *Analytics) RecordFavorite(req *http.Request, body FavoriteRequest) rules.ScriptResponse
- func (a *Analytics) RecordSavedSearch(req *http.Request, body SavedSearchRequest) rules.ScriptResponse
- func (a *Analytics) Routes() []plugins.Route
- type AnalyticsPreferences
- type ClickRecord
- type ClickSummary
- type ClickType
- type ConversionRecord
- type DetailedSummary
- type Error
- type FavoriteES
- type FavoriteRequest
- type GetInsight
- type Insight
- type InsightConfigType
- type InsightEnvironments
- type InsightReportAnalytics
- type InsightResponse
- type InsightResponseType
- type InsightStatus
- type InsightStatusEsDoc
- type InsightStatusRequest
- type InsightType
- type InsightsEnvironments
- type Link
- type Links
- type Location
- type MappingsMigration
- type QueryFilter
- type QueryParams
- type RecentDocument
- type RecentDocumentPublic
- type Recommendation
- type RecordUserSessionConfig
- type ReportAnalyticsRequest
- type RequestHIT
- type SavedSearchES
- type SavedSearchRequest
- type SavedSearchesFilters
- type SearchRecord
- type SummaryComparison
- type SummaryRecord
- type SummaryResponse
- type TTLMap
- type TTLMapTimestamp
- type UpdateConfig
- type User
- type UserSession
- type UserSessionMappingsMigration
Constants ¶
const ( XSearchQuery = "X-Search-Query" XSearchID = "X-Search-Id" XTimestamp = "X-timestamp" XSearchFilters = "X-Search-Filters" XSearchClickObjectID = "X-Search-Click-Object" XSearchClick = "X-Search-Click" XSearchClickPosition = "X-Search-ClickPosition" XSearchSuggestionsClick = "X-Search-Suggestions-Click" XSearchSuggestionsClickPosition = "X-Search-Suggestions-ClickPosition" XSearchConversion = "X-Search-Conversion" XSearchCustomEvent = "X-Search-CustomEvent" XSearchState = "X-Search-State" XUserID = "X-User-Id" )
Custom headers
const (
CustomEventsPrefix = "c_"
)
Variables ¶
var InsightConfig = []InsightConfigType{ { ID: NoResults, Insight: Insight{ Title: `"There are "+FormatNumber(ToFloat(TotalNoResultsSearches))+" no results searches"`, Description: `"No results searches create a poor user experience for your users."`, Condition: "TotalNoResultsSearches > 0", ShortLink: links.NoResultsSearches.ShortLink, Recommendations: []Recommendation{ { Title: "Language Settings", Description: "Set the language, stemming and stop words settings in the Language settings.", ShortLink: links.Language.ShortLink, }, { Title: "Search Settings", Description: "Ensure that the searchable fields are set. You can also enable the typo tolerance setting.", ShortLink: links.SearchSettings.ShortLink, }, { Title: "Synonyms", Description: "Map the no results search terms to data that's present in your index.", ShortLink: links.Synonyms.ShortLink, }, { Title: "Query Rules", Description: "Create a query rule to promote results for the no results search terms.", ShortLink: links.Rules.ShortLink, }, }, }, }, { ID: LowClicks, Insight: Insight{ Title: `"Less than "+AvgClickRate+"% of your searches receive a click"`, Description: `"Your searches saw an average click rate of "+AvgClickRate+"%."`, Condition: "AvgClickRate > 0 and AvgClickRate <= 5", Recommendations: []Recommendation{ { Title: "Language Settings", Description: "Set the language, stemming and stop words settings in the Language settings.", ShortLink: links.Language.ShortLink, }, { Title: "Search Settings", Description: "Ensure that the searchable fields are set correctly and weighted appropriately.", ShortLink: links.SearchSettings.ShortLink, }, { Title: "Query Rules", Description: "Create a query rule to promote more relevant results.", ShortLink: links.Rules.ShortLink, }, }, }, }, { ID: LowSuggestionsClicks, Insight: Insight{ Title: `"Less than "+AvgSuggestionsClickRate+"% of your auto suggestion searches receive a click"`, Description: `"Your auto suggestion searches saw an average click rate of "+AvgSuggestionsClickRate+"%."`, Condition: "AvgSuggestionsClickRate > 0 and AvgSuggestionsClickRate <= 5", Recommendations: []Recommendation{ { Title: "Language Settings", Description: "Set the language, stemming and stop words settings in the Language settings.", ShortLink: links.Language.ShortLink, }, { Title: "Search Settings", Description: "Ensure that the searchable fields are set correctly and weighted appropriately.", ShortLink: links.SearchSettings.ShortLink, }, { Title: "Query Rules", Description: "Create a query rule to promote more relevant results.", ShortLink: links.Rules.ShortLink, }, { Title: "Query suggestions", Description: "Set query suggestions to show suggestions recommendations based on analytics data.", ShortLink: links.QuerySuggestions.ShortLink, }, }, }, }, { ID: AvgClickPosition, Insight: Insight{ Title: `"The average click position for your results is "+AvgClickPosition`, Description: `"A higher value for average click position indicates that your users need to scroll through before they find what they are looking for."`, Condition: "AvgClickPosition >= 5", Recommendations: []Recommendation{ { Title: "Search Settings", Description: "Ensure that the searchable fields are set correctly and weighted appropriately. You can test with other search settings.", ShortLink: links.SearchSettings.ShortLink, }, }, }, }, { ID: PopularSearches, Insight: Insight{ Title: `"You have "+FormatNumber(ToFloat(PopularSearches))" popular searches"`, Description: `"Congrats! These terms are searched for at least 100 times by your users."`, Condition: "PopularSearches > 0", ShortLink: links.PopularSearches.ShortLink, Recommendations: []Recommendation{ { Title: "Query Rules", Description: "Create a query rule for these terms to merchandise other items.", ShortLink: links.Rules.ShortLink, }, }, }, }, { ID: PopularSearchesWithLowClicks, Insight: Insight{ Title: `"Less than "+AvgClickRatePopularSearches+"% of your popular searches receive a click"`, Description: `"On an average, your popular searches saw a click rate of "+AvgClickRatePopularSearches+"%."`, Condition: "PopularSearches > 0 and AvgClickRatePopularSearches <= 5", ShortLink: links.PopularSearches.ShortLink, Recommendations: []Recommendation{ { Title: "Language Settings", Description: "Set the language, stemming and stop words settings in the Language settings.", ShortLink: links.Language.ShortLink, }, { Title: "Search Settings", Description: "Ensure that the searchable fields are set correctly and weighted appropriately.", ShortLink: links.SearchSettings.ShortLink, }, { Title: "Query Rules", Description: "Create a query rule to promote more relevant results.", ShortLink: links.Rules.ShortLink, }, }, }, }, { ID: LongTailSearches, Insight: Insight{ Title: `"Analyze the long tail search terms"`, Description: `"Long-tail searches often tell you what your power users are looking for."`, Condition: "AvgQueryLength >= 4", Recommendations: []Recommendation{}, }, }, { ID: BounceRate, Insight: Insight{ Title: `"Your search bounce rate is "+AvgBounceRate+"%"`, Description: `"Bounce rate indicates sessions where a user left without interacting with the search."`, Condition: "AvgBounceRate > 50", Recommendations: []Recommendation{ { Title: "Improve your search experience", Description: "You can use external tools such as Hotjar to qualitatively understand the gaps in your search experience.", }, }, }, }, { ID: HighResponseTime, Insight: Insight{ Title: `FormatNumber(ToFloat(HighResponseTimeSearches))+" searches took more than a second"`, Description: `"At least 10% of your total searches are taking more than a second to return. A lower response time provides a better user experience."`, Condition: "HighResponseTimeSearches > 0", Recommendations: []Recommendation{ { Title: "Review Results Settings", Description: "You can set what fields to return and optimize your highlighting settings to improve the search response time.", ShortLink: links.ResultSettings.ShortLink, }, { Title: "Review Index settings", Description: "An optimal shard and replica setting can provide a better search response time.", ShortLink: links.IndexSettings.ShortLink, }, }, }, }, { ID: Error500, Insight: Insight{ Title: `FormatNumber(ToFloat(InternalServerErrors))+" searches returned an internal server error"`, Description: `"Internal server errors indicate an issue with the underlying ElasticSearch service."`, Condition: "InternalServerErrors > 0", ShortLink: links.RequestLogs.ShortLink, Recommendations: []Recommendation{ { Title: "Optimize your ElasticSearch configuration", Description: "Check with your service provider on what can be done to improve your search infrastructure's availability. If your search volume is growing, you may also want to look at upgrading the search servers.", }, }, }, }, { ID: Error400, Insight: Insight{ Title: `FormatNumber(ToFloat(BadRequestErrors))+" searches failed due to a client error"`, Condition: "BadRequestErrors > 0", Description: `"Your searches failed due to a bad request or an authentication error."`, ShortLink: links.RequestLogs.ShortLink, Recommendations: []Recommendation{ { Title: "Analyze your logs for errors.", }, }, }, }, }
InsightConfig can be used to configure the insights and recommendations. Please follow the instructions carefully before editing: 1. Insight title must be a valid expression from `expr` library, for example: '`"There are "+TotalNoResultsSearches+" no result searches"`'. 2. Insight is driven by the `Condition` property which is also an expression. 3. Check the `DetailedSummary` struct in `plugins/analytics/util.go` to know the env. variables available for expression. 4. You can also use markdown for the string fields for eg. 'Get the [reactivesearch.io](reactivesearch.io) support plan' 5. The order of the insights and recommendations will be determined from this config, so any changes in the order will affect the order in the UI.
var PreDefinedTermFilters = [...]string{"user_id", "ip"}
Need to define separately so we can decide whether to apply custom event prefix in field or not while querying ES.
Functions ¶
func AddEventPrefix ¶
Adds the prefix from custom event field
func ApplyCustomEventsEs7 ¶
ApplyCustomEventsEs7 applies the custom events to ES7 query
func FetchDocumentForSource ¶
FetchDocumentForSource will fetch the document based on the passed details
func GenerateRecentDocId ¶
GenerateRecentDocId will generate the recent document ID with the passed values.
func GetAnalyticsIndex ¶
func GetAnalyticsIndex() string
func GetCustomFilters ¶
GetCustomFilters will parse the custom filters from the query params map
func GetDocumentSuggestionsIndex ¶
func GetDocumentSuggestionsIndex() string
func HasSearchTypeOfQuery ¶
func HasSearchTypeOfQuery(rsRequestBody *querytranslate.RSQuery) bool
Returns true if request body has at least one type search query
func IsAnalyticsEnabled ¶
func IsAnalyticsEnabled() bool
IsAnalyticsEnabled will check if analytics is enabled or not and accordingly return the status.
func IsPreDefinedTermFilter ¶
func Recorder ¶
func Recorder() middleware.Middleware
Recorder parses and records the search requests made to elasticsearch along with some other user information in order to calculate and serve useful analytics.
func SetPreferencesInCache ¶
func SetPreferencesInCache(a AnalyticsPreferences)
SetPreferencesInCache will set the analytics preferences in cache.
Types ¶
type ActiveUserSession ¶
type ActiveUserSessionES ¶
type ActiveUserSessionES struct {
ID string
UserSession UserSession
}
type ActiveUserSessionItem ¶
type ActiveUserSessionItem struct {
// contains filtered or unexported fields
}
type ActiveUserSessionTTLMap ¶
type ActiveUserSessionTTLMap struct {
// contains filtered or unexported fields
}
func InitUserSession ¶
func InitUserSession(ln int, maxTTL int, initialValue *ActiveUserSessionTTLMap) (m *ActiveUserSessionTTLMap)
func (*ActiveUserSessionTTLMap) Delete ¶
func (m *ActiveUserSessionTTLMap) Delete(k string) (v *ActiveUserSession)
func (*ActiveUserSessionTTLMap) Get ¶
func (m *ActiveUserSessionTTLMap) Get(k string) (v *ActiveUserSession)
func (*ActiveUserSessionTTLMap) Len ¶
func (m *ActiveUserSessionTTLMap) Len() int
func (*ActiveUserSessionTTLMap) Put ¶
func (m *ActiveUserSessionTTLMap) Put(k string, v ActiveUserSession)
type Analytics ¶
type Analytics struct {
// contains filtered or unexported fields
}
Analytics plugin records and serves basic index or cluster level analytics.
func Instance ¶
func Instance() *Analytics
Instance returns the singleton instace of Analytics plugin. Note: Only this function must be used (both within and outside the package) to obtain the instance analytics in order to avoid stateless instances of the plugin.
func (*Analytics) AlternateRoutes ¶
Expose plugin specific routes
func (*Analytics) ESMiddleware ¶
func (a *Analytics) ESMiddleware() []middleware.Middleware
func (*Analytics) InitFunc ¶
InitFunc is a part of Plugin interface that gets executed only once, and initializes the dao, i.e. elasticsearch before the plugin is operational.
func (*Analytics) Name ¶
Name is a part of Plugin interface that returns the name of the plugin: 'analytics'.
func (*Analytics) RSMiddleware ¶
func (a *Analytics) RSMiddleware() []middleware.Middleware
func (*Analytics) RecordAnalytics ¶
func (a *Analytics) RecordAnalytics( request rules.ScriptRequest, rsRequestBody *querytranslate.RSQuery, response rules.ScriptResponse, indices []string, ) (*string, rules.ScriptResponse)
Records the analytics and returns query id and response body with query id
func (*Analytics) RecordClick ¶
func (a *Analytics) RecordClick(r *http.Request, body ClickRecord) rules.ScriptResponse
func (*Analytics) RecordConversion ¶
func (a *Analytics) RecordConversion(r *http.Request, body ConversionRecord) rules.ScriptResponse
func (*Analytics) RecordFavorite ¶
func (a *Analytics) RecordFavorite(req *http.Request, body FavoriteRequest) rules.ScriptResponse
func (*Analytics) RecordSavedSearch ¶
func (a *Analytics) RecordSavedSearch(req *http.Request, body SavedSearchRequest) rules.ScriptResponse
type AnalyticsPreferences ¶
type AnalyticsPreferences struct {
Enable *bool `json:"enable"`
}
func GetPreferencesFromCache ¶
func GetPreferencesFromCache() AnalyticsPreferences
GetPreferencesFromCache will return the analytics preferences from cache.
type ClickRecord ¶
type ClickRecord struct {
Query *string `json:"query"` // Optional
QueryID string `json:"query_id"` // Optional
ClickType ClickType `json:"click_type"` // Optional
ClickOn *map[string]int `json:"click_on"` // Required
UserID string `json:"user_id,omitempty"` // Optional
// TODO: Remove `event_data` in Next major version
EventData map[string]interface{} `json:"event_data,omitempty"` // Optional
CustomEvents map[string]interface{} `json:"custom_events,omitempty"` // Optional
Meta *map[string]interface{} `json:"meta"`
}
type ClickSummary ¶
type ClickType ¶
type ClickType int
func (ClickType) MarshalJSON ¶
MarshalJSON is the implementation of the Marshaler interface for marshaling ClickType type.
func (ClickType) String ¶
String is the implementation of Stringer interface that returns the string representation of ClickType type.
func (*ClickType) UnmarshalJSON ¶
UnmarshalJSON is the implementation of the Unmarshaler interface for un-marshaling ClickType type.
type ConversionRecord ¶
type DetailedSummary ¶
type DetailedSummary struct {
AvgBounceRate float64 `json:"avg_bounce_rate"`
AvgUserSessionDuration float64 `json:"avg_user_session_duration"`
AvgClickRate float64 `json:"avg_click_rate"`
AvgClickPosition float64 `json:"avg_click_position"`
AvgResultClickPosition float64 `json:"avg_results_click_position"`
AvgSuggestionsClickPosition float64 `json:"avg_suggestions_click_position"`
AvgSuggestionsClickRate float64 `json:"avg_suggestions_click_rate"`
AvgConversionRate float64 `json:"avg_conversion_rate"`
TotalResultsCount float64 `json:"total_results_count"`
TotalSearches float64 `json:"total_searches"`
TotalUsers float64 `json:"total_users"`
TotalUserSessions float64 `json:"total_user_sessions"`
TotalBounceUsers float64 `json:"total_bounce_users"`
TotalClicks float64 `json:"total_clicks"`
TotalSuggestionsClicks float64 `json:"total_suggestions_clicks"`
TotalResultsClicks float64 `json:"total_results_clicks"`
TotalConversions float64 `json:"total_conversions"`
TotalNoResultsSearches float64 `json:"total_no_results_searches"`
NoResultsRate float64 `json:"no_results_rate"`
PopularSearches float64 `json:"popular_searches"`
AvgClickRatePopularSearches float64 `json:"avg_click_rate_popular_searches"`
AvgQueryLength float64 `json:"avg_query_length"`
InternalServerErrors float64 `json:"internal_server_errors"`
BadRequestErrors float64 `json:"bad_request_errors"`
HighResponseTimeSearches float64 `json:"high_response_time_searches"`
}
DetailedSummary represents the detailed summary to extract the insights
type FavoriteES ¶
type FavoriteES struct {
Id *string `json:"id,omitempty"`
QueryId *string `json:"query_id,omitempty"`
FavoriteOn *string `json:"favorite_on,omitempty"`
Source *string `json:"source,omitempty"`
UserId *string `json:"user_id,omitempty"`
CustomEvents *map[string]interface{} `json:"custom_events,omitempty"`
CreatedAt *int64 `json:"created_at,omitempty"`
UpdatedAt *int64 `json:"updated_at,omitempty"`
TimeStamp *string `json:"timestamp,omitempty"`
SearchQuery *string `json:"search_query,omitempty"`
SearchQueryCharsLength *int `json:"search_characters_length,omitempty"`
Meta *map[string]interface{} `json:"meta,omitempty"`
}
type FavoriteRequest ¶
type FavoriteRequest struct {
Id *string `json:"id,omitempty"`
QueryId *string `json:"query_id,omitempty"`
FavoriteOn *string `json:"favorite_on,omitempty"`
Source *map[string]interface{} `json:"source,omitempty"`
UserId *string `json:"user_id,omitempty"`
CustomEvents *map[string]interface{} `json:"custom_events,omitempty"`
Meta *map[string]interface{} `json:"meta,omitempty"`
}
type GetInsight ¶
type GetInsight struct {
Summary SummaryRecord
Insights []InsightResponseType
SavedInsights []InsightResponseType
ReadInsights []InsightResponseType
}
GetInsight represents the returned shape for getInsights method
type Insight ¶
type Insight struct {
// Represents the insight title, must be a valid expression
Title string `json:"title"`
// Represents the insight description, must be a valid expression
Description string `json:"description"`
ShortLink string `json:"short_link"`
Recommendations []Recommendation `json:"recommendations"`
// expression from the `expr` package to evaluate the insight
Condition string `json:"condition"`
}
Insight represents the insight object
type InsightConfigType ¶
type InsightConfigType struct {
ID InsightType `json:"id"`
Insight Insight `json:"insight"`
}
InsightConfigType represents the insight object in the config
type InsightEnvironments ¶
type InsightEnvironments struct {
AvgBounceRate string
AvgUserSessionDuration string
AvgClickRate string
AvgClickPosition string
AvgResultClickPosition string
AvgSuggestionsClickPosition string
AvgSuggestionsClickRate string
AvgConversionRate string
TotalResultsCount string
TotalSearches string
TotalUsers string
TotalUserSessions string
TotalBounceUsers string
TotalClicks string
TotalSuggestionsClicks string
TotalResultsClicks string
TotalConversions string
TotalNoResultsSearches string
NoResultsRate string
PopularSearches string
AvgClickRatePopularSearches string
AvgQueryLength string
InternalServerErrors string
BadRequestErrors string
HighResponseTimeSearches string
ToFloat func(string) float64
ToString func(float64, int) string
FormatNumber func(float64) string
}
InsightEnvironments represents the environment variables for Insight Title
type InsightReportAnalytics ¶
type InsightReportAnalytics struct {
Title string `json:"title"`
Description string `json:"description"`
Link string `json:"link"`
}
InsightReportAnalytics represents the insight object
type InsightResponse ¶
type InsightResponse struct {
/* Represents the recommendation title, for an example: "There are {value} no result searches".
{value} is a variable which will be replaced by the actual value
*/
Title string `json:"title"`
Description string `json:"description"`
Recommendations []Recommendation `json:"recommendations"`
ShortLink string `json:"short_link"`
}
InsightResponse represents the insight response object
type InsightResponseType ¶
type InsightResponseType struct {
ID InsightType `json:"id"`
Insight InsightResponse `json:"insight"`
}
InsightResponseType represents the insight endpoint response
type InsightStatus ¶
type InsightStatus int
InsightStatus represents the type of the insight status
const ( // Saved represents the saved status for insight Saved InsightStatus = iota // Read represents the read status for insight Read // Deleted represents the deleted status for insight Deleted )
func (InsightStatus) MarshalJSON ¶
func (o InsightStatus) MarshalJSON() ([]byte, error)
MarshalJSON is the implementation of the Marshaler interface for marshaling InsightStatus type.
func (InsightStatus) String ¶
func (o InsightStatus) String() string
String is the implementation of Stringer interface that returns the string representation of InsightStatus type.
func (*InsightStatus) UnmarshalJSON ¶
func (o *InsightStatus) UnmarshalJSON(bytes []byte) error
UnmarshalJSON is the implementation of the Unmarshaler interface for un-marshaling InsightStatus type.
type InsightStatusEsDoc ¶
type InsightStatusEsDoc struct {
Saved []InsightType `json:"saved"`
Read []InsightType `json:"read"`
Deleted []InsightType `json:"deleted"`
}
InsightStatusEsDoc represents the ES doc for insight status
type InsightStatusRequest ¶
type InsightStatusRequest struct {
ID *InsightType `json:"id"`
Status InsightStatus `json:"status"`
}
InsightStatusRequest represents the request body to update the status
type InsightType ¶
type InsightType int
InsightType represents the type of the insight
const ( // NoResults represents the no_results property in insight NoResults InsightType = iota // LowClicks represents the low_clicks property in insight LowClicks // LowSuggestionsClicks represents the `low_suggestions_clicks` property in insight LowSuggestionsClicks // AvgClickPosition represents the avg_click_position property in insight AvgClickPosition // PopularSearches represents the popular_searches property in insight PopularSearches // PopularSearchesWithLowClicks represents the popular_searches_with_low_clicks property in insight PopularSearchesWithLowClicks // LongTailSearches represents the long_tail_searches property in insight LongTailSearches // BounceRate represents the bounce_rate property in insight BounceRate // HighResponseTime represents the high_response_time property in insight HighResponseTime // Error500 represents the error_500 property in insight Error500 // Error400 represents the error_400 property in insight Error400 )
func (InsightType) MarshalJSON ¶
func (o InsightType) MarshalJSON() ([]byte, error)
MarshalJSON is the implementation of the Marshaler interface for marshaling InsightType type.
func (InsightType) String ¶
func (o InsightType) String() string
String is the implementation of Stringer interface that returns the string representation of InsightType type.
func (*InsightType) UnmarshalJSON ¶
func (o *InsightType) UnmarshalJSON(bytes []byte) error
UnmarshalJSON is the implementation of the Unmarshaler interface for un-marshaling InsightType type.
type InsightsEnvironments ¶
type InsightsEnvironments struct {
DateRange string `json:"date_range"` // format Apr 1 - Apr 30
NumberOfInsights int `json:"number_of_insights"`
Insights []InsightReportAnalytics `json:"insights"`
}
InsightsEnvironments represents the insights environment variables available for mail template for analytics
type Links ¶
type Links struct {
Language Link
Rules Link
SearchSettings Link
Synonyms Link
QuerySuggestions Link
ResultSettings Link
IndexSettings Link
RequestLogs Link
NoResultsSearches Link
PopularSearches Link
}
Links represents all link
type MappingsMigration ¶
type MappingsMigration struct {
NewMapping string
// contains filtered or unexported fields
}
func (MappingsMigration) ConditionCheck ¶
func (m MappingsMigration) ConditionCheck() (bool, *util.Error)
func (MappingsMigration) IsAsync ¶
func (m MappingsMigration) IsAsync() bool
func (MappingsMigration) Script ¶
func (m MappingsMigration) Script() *util.Error
type QueryFilter ¶
type QueryFilter struct {
Type string // Valid types are `exists` => We can add new types as per need
Field string
NestedPath string
}
TODO: we can use enums for query types
type QueryParams ¶
func RangeQueryParams ¶
func RangeQueryParams(values url.Values) QueryParams
RangeQueryParams exposes the rangeQueryParams method to make it accessible in the whole package.
type RecentDocument ¶
type RecentDocument struct {
DocumentId *string `json:"document_id"`
Source *map[string]interface{} `json:"source"`
Users *map[string]int64 `json:"users"`
Index *string `json:"index"`
}
RecentDocument will contain details about the recent document viewed by an user.
func (*RecentDocument) ToPublic ¶
func (r *RecentDocument) ToPublic(userId string) RecentDocumentPublic
ToPublic will convert the internal values into a public structure
type RecentDocumentPublic ¶
type RecentDocumentPublic struct {
DocumentId *string `json:"document_id"`
UserId *string `json:"user_id"`
Index *string `json:"index"`
Source *map[string]interface{} `json:"source"`
LastAccessed *int64 `json:"last_accessed,omitempty"`
}
RecentDocumentPublic will be the visible recent document that the API will accept and return
func (*RecentDocumentPublic) ToInternal ¶
func (r *RecentDocumentPublic) ToInternal() RecentDocument
ToInternal will convert the public document to internal document.
This function will not validate the values to make sure that they are present.
This function will only be used if the document doesn't already exist in the index. If it already exists, we will do an `_update_by_query` with a script to inject the `user_id` in the `users` map.
type Recommendation ¶
type Recommendation struct {
Title string `json:"title"`
Description string `json:"description"`
// Represents the short link for e.g '/cluster/no-results-searches'
ShortLink string `json:"short_link"`
// Represents the full link for e.g 'https://dash.reactivesearch.io/cluster/no-results-searches'
LongLink string `json:"long_link"`
}
Recommendation represents the structure of the insight recommendation
type RecordUserSessionConfig ¶
type RecordUserSessionConfig struct {
// contains filtered or unexported fields
}
type ReportAnalyticsRequest ¶
type ReportAnalyticsRequest struct {
Summary SummaryRecord `json:"summary"`
SummaryComparison SummaryComparison `json:"summary_comparison"`
Insights InsightsEnvironments `json:"insights"`
Users []string `json:"users"`
FeatureCustomEvents bool `json:"feature_custom_events"`
}
ReportAnalyticsRequest represents the request body for report analytics
type RequestHIT ¶
type SavedSearchES ¶
type SavedSearchES struct {
QueryId *string `json:"query_id,omitempty"`
SavedSearchId *string `json:"save_search_id,omitempty"`
SavedSearchName *string `json:"save_search_name,omitempty"`
SavedSearchMeta *map[string]interface{} `json:"save_search_meta,omitempty"`
UserId *string `json:"user_id,omitempty"`
CustomEvents *map[string]interface{} `json:"custom_events,omitempty"`
SearchState querytranslate.Endpoint `json:"search_state,omitempty"`
CreatedAt *int64 `json:"created_at,omitempty"`
UpdatedAt *int64 `json:"updated_at,omitempty"`
TimeStamp *string `json:"timestamp,omitempty"`
SearchQuery *string `json:"search_query,omitempty"`
SearchQueryCharsLength *int `json:"search_characters_length,omitempty"`
}
type SavedSearchRequest ¶
type SavedSearchRequest struct {
QueryId *string `json:"query_id,omitempty"`
SavedSearchId *string `json:"save_search_id,omitempty"`
SavedSearchName *string `json:"save_search_name,omitempty"`
SavedSearchMeta *map[string]interface{} `json:"save_search_meta,omitempty"`
UserId *string `json:"user_id,omitempty"`
CustomEvents *map[string]interface{} `json:"custom_events,omitempty"`
}
type SavedSearchesFilters ¶
type SearchRecord ¶
type SearchRecord struct {
Query *string `json:"query"` // Required
QueryID string `json:"query_id"` // Optional
Filters *map[string]string `json:"filters,omitempty"` // Optional
Impressions *[]RequestHIT `json:"impressions,omitempty"` // Optional
TotalHits *int64 `json:"total_hits,omitempty"` // Optional
UserID string `json:"user_id,omitempty"` // Optional
// TODO: Remove `event_data` in Next major version
EventData map[string]interface{} `json:"event_data,omitempty"` // Optional
CustomEvents map[string]interface{} `json:"custom_events,omitempty"` // Optional
Meta *map[string]interface{} `json:"meta"`
}
type SummaryComparison ¶
type SummaryComparison struct {
AvgBounceRateComparison float64 `json:"avg_bounce_rate_sc"`
AvgBounceRatePrevious float64 `json:"avg_bounce_rate_prev"`
AvgUserSessionDurationComparison float64 `json:"avg_user_session_duration_sc"`
AvgUserSessionDurationPrevious float64 `json:"avg_user_session_duration_prev"`
AvgClickRateComparison float64 `json:"avg_click_rate_sc"`
AvgClickRatePrevious float64 `json:"avg_click_rate_prev"`
AvgClickPositionComparison float64 `json:"avg_click_position_sc"`
AvgClickPositionPrevious float64 `json:"avg_click_position_prev"`
AvgResultClickPositionComparison float64 `json:"avg_results_click_position_sc"`
AvgResultClickPositionPrevious float64 `json:"avg_results_click_position_prev"`
AvgSuggestionsClickPositionComparison float64 `json:"avg_suggestions_click_position_sc"`
AvgSuggestionsClickPositionPrevious float64 `json:"avg_suggestions_click_position_prev"`
AvgSuggestionsClickRateComparison float64 `json:"avg_suggestions_click_rate_sc"`
AvgSuggestionsClickRatePrevious float64 `json:"avg_suggestions_click_rate_prev"`
AvgConversionRateComparison float64 `json:"avg_conversion_rate_sc"`
AvgConversionRatePrevious float64 `json:"avg_conversion_rate_prev"`
TotalResultsCountComparison float64 `json:"total_results_count_sc"`
TotalResultsCountPrevious float64 `json:"total_results_count_prev"`
TotalSearchesComparison float64 `json:"total_searches_sc"`
TotalSearchesPrevious float64 `json:"total_searches_prev"`
TotalUsersComparison float64 `json:"total_users_sc"`
TotalUsersPrevious float64 `json:"total_users_prev"`
TotalUserSessionsComparison float64 `json:"total_user_sessions_sc"`
TotalUserSessionsPrevious float64 `json:"total_user_sessions_prev"`
TotalBounceUsersComparison float64 `json:"total_bounce_users_sc"`
TotalBounceUsersPrevious float64 `json:"total_bounce_users_prev"`
TotalClicksComparison float64 `json:"total_clicks_sc"`
TotalClicksPrevious float64 `json:"total_clicks_prev"`
TotalSuggestionsClicksComparison float64 `json:"total_suggestions_clicks_sc"`
TotalSuggestionsClicksPrevious float64 `json:"total_suggestions_clicks_prev"`
TotalResultsClicksComparison float64 `json:"total_results_clicks_sc"`
TotalResultsClicksPrevious float64 `json:"total_results_clicks_prev"`
TotalConversionsComparison float64 `json:"total_conversions_sc"`
TotalConversionsPrevious float64 `json:"total_conversions_prev"`
TotalNoResultsSearchesComparison float64 `json:"total_no_results_searches_sc"`
TotalNoResultsSearchesPrevious float64 `json:"total_no_results_searches_prev"`
NoResultsRateComparison float64 `json:"no_results_rate_sc"`
NoResultsRatePrevious float64 `json:"no_results_rate_prev"`
}
SummaryComparison represents the analytics summary comparison environment variables available for mail template for analytics
type SummaryRecord ¶
type SummaryRecord struct {
AvgBounceRate float64 `json:"avg_bounce_rate"`
AvgUserSessionDuration float64 `json:"avg_user_session_duration"`
AvgClickRate float64 `json:"avg_click_rate"`
AvgClickPosition float64 `json:"avg_click_position"`
AvgResultClickPosition float64 `json:"avg_results_click_position"`
AvgSuggestionsClickPosition float64 `json:"avg_suggestions_click_position"`
AvgSuggestionsClickRate float64 `json:"avg_suggestions_click_rate"`
AvgConversionRate float64 `json:"avg_conversion_rate"`
TotalResultsCount float64 `json:"total_results_count"`
TotalSearches float64 `json:"total_searches"`
TotalUsers float64 `json:"total_users"`
TotalUserSessions float64 `json:"total_user_sessions"`
TotalBounceUsers float64 `json:"total_bounce_users"`
TotalClicks float64 `json:"total_clicks"`
TotalSuggestionsClicks float64 `json:"total_suggestions_clicks"`
TotalResultsClicks float64 `json:"total_results_clicks"`
TotalConversions float64 `json:"total_conversions"`
TotalNoResultsSearches float64 `json:"total_no_results_searches"`
NoResultsRate float64 `json:"no_results_rate"`
}
SummaryRecord represents the summary record
type SummaryResponse ¶
type SummaryResponse struct {
Summary SummaryRecord `json:"summary"`
CompateTimeframe *SummaryRecord `json:"compare_timeframe,omitempty"`
}
SummaryResponse represents the summary endpoint response struct
type TTLMap ¶
type TTLMap struct {
// contains filtered or unexported fields
}
func InitSession ¶
func (*TTLMap) DeleteStaleSessions ¶
TODO: Running a loop on active sessions is not performant It happens synchronously so it would affect the search latency
type TTLMapTimestamp ¶
type TTLMapTimestamp struct {
// contains filtered or unexported fields
}
func InitTimestampSession ¶
func InitTimestampSession(ln int, maxTTL int) (m *TTLMapTimestamp)
func (*TTLMapTimestamp) Get ¶
func (m *TTLMapTimestamp) Get(k string) (v int64)
func (*TTLMapTimestamp) Len ¶
func (m *TTLMapTimestamp) Len() int
func (*TTLMapTimestamp) Put ¶
func (m *TTLMapTimestamp) Put(k string, v int64)
type UpdateConfig ¶
type UserSession ¶
type UserSession struct {
StartTime *int64 `json:"start_time,omitempty"`
LastInteractionTime *int64 `json:"last_interaction_time,omitempty"`
Duration *int64 `json:"duration,omitempty"`
UserID *string `json:"user_id,omitempty"`
Indices *[]string `json:"indices,omitempty"`
Bounce *bool `json:"bounce,omitempty"`
TimeStamp string `json:"timestamp,omitempty"`
IP *string `json:"ip,omitempty"`
}
UserSession represents the user session record in the Elasticsearch
type UserSessionMappingsMigration ¶
type UserSessionMappingsMigration struct {
NewMapping string
// contains filtered or unexported fields
}
func (UserSessionMappingsMigration) ConditionCheck ¶
func (u UserSessionMappingsMigration) ConditionCheck() (bool, *util.Error)
func (UserSessionMappingsMigration) IsAsync ¶
func (m UserSessionMappingsMigration) IsAsync() bool
func (UserSessionMappingsMigration) Script ¶
func (u UserSessionMappingsMigration) Script() *util.Error