Documentation ¶
Index ¶
- Constants
- Variables
- func CompareResults(base int, exp int) int
- func CreateGrammarIndex(esc *elastic.Client, indexDate string) error
- func CsvToString(records [][]string) (error, string)
- func DeleteGrammarIndex(esc *elastic.Client, indexDate string) error
- func EvalResultDiffHtml(resultDiff ResultDiff) (string, error)
- func EvalResultsDiffsCount(evalSet []EvalQuery, expResults []EvalResult, baseResults []EvalResult) (int, error)
- func EvalResultsDiffsHtml(resultsDiffs ResultsDiffs) (string, error)
- func EvalScrapeStreaming(in chan EvalQuery, out chan EvalResult, serverUrl string, ...) error
- func ExpectationToString(e Expectation) string
- func FilterValueToUid(value string) string
- func FoldGrammars(first Grammars, second Grammars)
- func FoldGrammarsV2(first GrammarsV2, second GrammarsV2)
- func GoodExpectations(expectations []Expectation) int
- func GrammarFilterVariablesMatch(intent string, variablesByPhrase VariablesByPhrase, cm cache.CacheManager)
- func GrammarIndexName(lang string, indexDate string) string
- func GrammarIndexNameForServing(lang string) string
- func GrammarIndexNameFunc(indexDate string) es.IndexNameByLang
- func GrammarVariablesMatch(intent string, vMap map[string][]string, cm cache.CacheManager) bool
- func HitMatchesExpectation(hit *elastic.SearchHit, hitSource HitSource, e Expectation) bool
- func HitSourcesEqual(a, b HitSource) bool
- func IndexGrammars(esc *elastic.Client, indexDate string, grammars GrammarsV2, ...) error
- func LoadVariableTranslations(variableFile string, variableName string, esc *elastic.Client, tc *TokensCache) (map[string]map[string][][]*TokenNode, error)
- func MakeYearVariablesV2() map[string][]string
- func NewFilteredResultsSearchRequest(text string, filters map[string][]string, contentType string, ...) ([]*elastic.SearchRequest, error)
- func NewGammarPerculateRequest(query *Query, language string, preference string) *elastic.SearchRequest
- func NewResultsSearchRequest(options SearchRequestOptions) (*elastic.SearchRequest, error)
- func NewResultsSearchRequests(options SearchRequestOptions) ([]*elastic.SearchRequest, error)
- func NewResultsSuggestGrammarV2CompletionRequest(query *Query, language string, preference string) *elastic.SearchRequest
- func NewResultsSuggestRequest(resultTypes []string, index string, query Query, preference string) *elastic.SearchRequest
- func NewResultsSuggestRequests(resultTypes []string, query Query, preference string) []*elastic.SearchRequest
- func NewSuggestGammarV2Request(query *Query, language string, preference string, hitType *string) *elastic.SearchRequest
- func PrintManyTokens(tokens [][]*TokenNode, prefix string, variables map[string]*Variable)
- func PrintOriginalPhrase(t []*TokenNode, variables map[string]*Variable)
- func PrintToken(token *TokenNode, variables map[string]*Variable)
- func PrintTokens(tokens []*TokenNode, prefix string, variables map[string]*Variable)
- func ReadEvalSets(glob string) (map[string][]EvalQuery, error)
- func ResultsByExpectation(queries []EvalQuery, results EvalResults) [][]string
- func SplitPatterns(patterns []*TokenNode, variables map[string]*Variable) ([]*TokenNode, []*TokenNode)
- func SuggestionHasOptions(ss elastic.SearchSuggest) bool
- func TokenNodesToString(root []*TokenNode, variables map[string]*Variable) string
- func TokensMatch(tokens []*TokenNode, patterns [][]*TokenNode, matchPrefixes bool, ...) (bool, []VariableValue, []*TokenNode, error)
- func TokensSingleMatch(tokens []*TokenNode, patterns []*TokenNode, matchPrefixes bool, ...) (bool, []VariableValue, []*TokenNode, error)
- func VariablesAsString(vars []string) string
- func VariablesFromString(vars string) []string
- func VariablesMapToString(variablesMap map[string][]string) string
- func WriteResults(path string, queries []EvalQuery, results EvalResults) error
- func WriteResultsByExpectation(path string, queries []EvalQuery, results EvalResults) ([][]string, error)
- func WriteToCsv(path string, records [][]string) error
- func WriteVsGoldenHTML(vsGoldenHtml string, records [][]string, goldenRecords [][]string, ...) error
- func YearScorePenalty(vMap map[string][]string) float64
- type ClassificationIntent
- type CreatedSearchClicks
- type CreatedSearchLogs
- type CrossIter
- type ESEngine
- func (e *ESEngine) AddIntentSecondRound(h *elastic.SearchHit, intent Intent, query Query) (error, *Intent, *Query)
- func (e *ESEngine) AddIntents(query *Query, preference string, sortBy string, searchTags bool, ...) ([]Intent, error)
- func (e *ESEngine) CombineResultsToSingleHit(resultsByLang map[string]*elastic.SearchResult, hitType string) (map[string]*elastic.SearchResult, error)
- func (e *ESEngine) DoSearch(ctx context.Context, query Query, sortBy string, from int, size int, ...) (*QueryResult, error)
- func (e *ESEngine) GetSuggestions(ctx context.Context, query Query, preference string) (interface{}, error)
- func (e *ESEngine) GetTypoSuggest(query Query, filterIntents []Intent) (null.String, error)
- func (e *ESEngine) IntentsToResults(query *Query) (error, map[string]*elastic.SearchResult)
- func (e *ESEngine) NativizeTweetsHitForClient(hit *elastic.SearchHit, innerHitsKey string) error
- func (e *ESEngine) SearchByFilterIntents(filterIntents []Intent, filters map[string][]string, originalSearchTerm string, ...) (map[string][]FilteredSearchResult, error)
- func (e *ESEngine) SearchGrammars(query *Query) ([]Intent, error)
- func (e *ESEngine) SearchGrammarsV2(query *Query, from int, size int, sortBy string, resultTypes []string, ...) ([]Intent, []Intent, error)
- func (e *ESEngine) SearchTweets(query Query, sortBy string, from int, size int, preference string) (map[string]*elastic.SearchResult, error)
- func (e *ESEngine) SuggestGrammars(query *Query) (map[string][]VariablesByPhrase, error)
- func (e *ESEngine) SuggestGrammarsV2(query *Query, preference string) (map[string][]VariablesByPhrase, error)
- func (e *ESEngine) VariableMapToFilterValues(vMap map[string][]string, language string) []FilterValue
- type ESManager
- type Engine
- type EvalQuery
- type EvalResult
- type EvalResults
- type Expectation
- type FileVariable
- type Filter
- type FilterValue
- type FilteredSearchResult
- type Grammar
- type GrammarIntent
- type GrammarRule
- type GrammarRuleWithPercolatorQuery
- type GrammarV2
- type Grammars
- type GrammarsV2
- type HitDiff
- type HitSource
- type Intent
- type Loss
- type OriginalTokenNode
- func (otn *OriginalTokenNode) OriginalFullPhraseToString() string
- func (otn *OriginalTokenNode) OriginalVariablePrefixToString() string
- func (otn *OriginalTokenNode) OriginalVariableToString() string
- func (otn *OriginalTokenNode) SkippedPrefixToString() string
- func (otn *OriginalTokenNode) SkippedSuffixToString() string
- type PhrasesByVariables
- type PhrasesWithOrigin
- func CopyPhrasesWithOrigin(p []*PhrasesWithOrigin) []*PhrasesWithOrigin
- func MakePhrasesWithOrigin(prefix, phrase, suffix, token string) *PhrasesWithOrigin
- func MakeVariablePhraseWithOrigin(variable, prefix, suffix string) *PhrasesWithOrigin
- func OriginalTokenNodesToPhrases(otns []*OriginalTokenNode, variables map[string]*Variable, ...) []*PhrasesWithOrigin
- func TokenNodesToPhrases(root []*TokenNode, variables map[string]*Variable, reduceVariables bool) []*PhrasesWithOrigin
- func (p *PhrasesWithOrigin) Invalidate()
- func (p *PhrasesWithOrigin) Join(s string) string
- func (p *PhrasesWithOrigin) OriginalJoin() string
- func (p *PhrasesWithOrigin) Reduce(variableName, variableValue, prefix, suffix string)
- func (p *PhrasesWithOrigin) ToString() string
- func (p *PhrasesWithOrigin) VariableValuesJoin() string
- func (pwo *PhrasesWithOrigin) VariablesMap() (map[string][]string, string)
- type Query
- type QueryResult
- type ResultDiff
- type ResultsDiffs
- func EvalQuerySetDiff(evalSet []EvalQuery, baseServerUrl, expServerUrl string, diffsLimit int32) (ResultsDiffs, error)
- func EvalResultsDiffs(evalSet []EvalQuery, expResults []EvalResult, baseResults []EvalResult) (ResultsDiffs, error)
- func EvalSearchDataQuerySetsDiff(language, baseServerUrl, expServerUrl string, diffsLimit int32) ([]ResultsDiffs, error)
- type SearchClick
- type SearchLog
- type SearchLogger
- func (searchLogger *SearchLogger) GetAllClicks() ([]SearchClick, error)
- func (searchLogger *SearchLogger) GetAllQueries(s *elastic.SliceQuery) ([]SearchLog, error)
- func (searchLogger *SearchLogger) GetLattestQueries(s *elastic.SliceQuery, gte null.String, ascending null.Bool) ([]SearchLog, error)
- func (searchLogger *SearchLogger) LogClick(mdbUid string, index string, resultType string, rank int, searchId string) error
- func (searchLogger *SearchLogger) LogSearch(query Query, sortBy string, from int, size int, searchId string, ...) error
- func (searchLogger *SearchLogger) LogSearchError(query Query, sortBy string, from int, size int, searchId string, ...) error
- type SearchRequestOptions
- type Span
- type TimeLog
- type TimeLogMap
- type Token
- type TokenNode
- type TokensCache
- type TokensCacheElement
- type Translations
- type TranslationsV2
- func GeneratePositionVariables(db *sql.DB) (TranslationsV2, error)
- func LoadHolidayTranslationsFromDB(db *sql.DB) (TranslationsV2, error)
- func LoadProgramNameTranslationsFromDB(db *sql.DB) (TranslationsV2, error)
- func LoadSourceNameTranslationsFromDB(db *sql.DB) (TranslationsV2, error)
- func LoadVariableTranslationsFromFile(variableFile string, variableName string) (TranslationsV2, error)
- type Variable
- type VariableValue
- type VariablesByLang
- type VariablesByName
- type VariablesByPhrase
- func TokensSearch(a []*TokenNode, b [][]*TokenNode, variables map[string]*Variable) (VariablesByPhrase, error)
- func TokensSingleSearch(a []*TokenNode, b []*TokenNode, variables map[string]*Variable) (VariablesByPhrase, error)
- func TokensSingleSearchTest(a []*TokenNode, b []*TokenNode, variables map[string]*Variable) (VariablesByPhrase, error)
- type VariablesV2
- type YearVariable
Constants ¶
const ( GRAMMAR_BOOST = 100.0 GRAMMAR_BOOST_KEYWORD = 300.0 GRAMMAR_SUGGEST_SIZE = 30 GRAMMAR_SEARCH_SIZE = 2000 GRAMMAR_PERCULATE_SIZE = 5 PERCULATE_HIGHLIGHT_SEPERATOR = '$' )
const ( EVAL_SET_EXPECTATION_FIRST_COLUMN = 4 EVAL_SET_EXPECTATION_LAST_COLUMN = 8 )
const ( SQ_SERVER_ERROR = iota SQ_NO_EXPECTATION = iota SQ_BAD_STRUCTURE = iota SQ_UNKNOWN = iota SQ_REGULAR = iota SQ_GOOD = iota )
Search quality enum. Order important, the lower (higher integer) the better.
const ( CR_WIN = iota CR_LOSS = iota CR_SAME = iota CR_NO_EXPECTATION = iota CR_ERROR = iota )
Compare results classification.
const ( ET_NOT_SET = -1 ET_CONTENT_UNITS = iota ET_COLLECTIONS = iota ET_LESSONS = iota ET_PROGRAMS = iota ET_SOURCES = iota ET_EVENTS = iota ET_LANDING_PAGE = iota ET_BLOG_OR_TWEET = iota ET_EMPTY = iota ET_FAILED_PARSE = iota ET_BAD_STRUCTURE = iota ET_FAILED_SQL = iota )
const ( FILTER_NAME_SOURCE = "source" FILTER_NAME_TOPIC = "topic" FILTER_NAME_CONTENT_TYPE = "contentType" FILTER_NAME_HOLIDAYS = "holidays" PREFIX_LATEST = "[latest]" BLOG_OR_TWEET_MARK = "blog_or_tweet" )
const ( // Content boost. TITLE_BOOST = 2.0 DESCRIPTION_BOOST = 1.2 FULL_TITLE_BOOST = 1.1 DEFAULT_BOOST = 1.0 // Max slop. SLOP = 100 // Following two boosts may be agregated. // Boost for standard anylyzer, i.e., without stemming. STANDARD_BOOST = 1.2 // Boost for exact phrase match, without slop. EXACT_BOOST = 1.5 SPAN_NEAR_BOOST = 0.01 MIN_SCORE_FOR_RESULTS = 0.01 NUM_SUGGESTS = 30 )
const (
GRAMMARS_INDEX_BASE_NAME = "grammars"
)
const (
START_YEAR = 1996
)
Variables ¶
var COMPARE_RESULTS_NAME = map[int]string{ CR_WIN: "Win", CR_LOSS: "Loss", CR_SAME: "Same", CR_ERROR: "Error", }
var EXPECTATIONS_FOR_EVALUATION = map[int]bool{ ET_CONTENT_UNITS: true, ET_COLLECTIONS: true, ET_LESSONS: true, ET_PROGRAMS: true, ET_SOURCES: true, ET_LANDING_PAGE: true, ET_BLOG_OR_TWEET: true, ET_EMPTY: false, ET_FAILED_PARSE: false, ET_BAD_STRUCTURE: true, ET_FAILED_SQL: true, }
var EXPECTATION_HIT_TYPE = map[int]string{ ET_CONTENT_UNITS: consts.ES_RESULT_TYPE_UNITS, ET_COLLECTIONS: consts.ES_RESULT_TYPE_COLLECTIONS, ET_LESSONS: consts.INTENT_HIT_TYPE_LESSONS, ET_PROGRAMS: consts.INTENT_HIT_TYPE_PROGRAMS, ET_SOURCES: consts.ES_RESULT_TYPE_SOURCES, ET_LANDING_PAGE: consts.GRAMMAR_TYPE_LANDING_PAGE, }
var EXPECTATION_TO_NAME = map[int]string{ ET_CONTENT_UNITS: "et_content_units", ET_COLLECTIONS: "et_collections", ET_LESSONS: "et_lessons", ET_PROGRAMS: "et_programs", ET_SOURCES: "et_sources", ET_BLOG_OR_TWEET: "et_blog_or_tweet", ET_LANDING_PAGE: "et_landing_page", ET_EMPTY: "et_empty", ET_FAILED_PARSE: "et_failed_parse", ET_BAD_STRUCTURE: "et_bad_structure", ET_FAILED_SQL: "et_failed_sql", }
var EXPECTATION_URL_PATH = map[int]string{ ET_CONTENT_UNITS: "cu", ET_COLLECTIONS: "c", ET_LESSONS: "lessons", ET_PROGRAMS: "programs", ET_SOURCES: "sources", ET_EVENTS: "events", }
var FLAT_REPORT_HEADERS = []string{
"Language", "Query", "Weight", "Bucket", "Comment",
"Expectation", "Parsed", "SearchQuality", "Rank"}
var LANDING_PAGES = map[string]string{ "lessons": consts.GRAMMAR_INTENT_LANDING_PAGE_LESSONS, "lessons/daily": consts.GRAMMAR_INTENT_LANDING_PAGE_LESSONS, "lessons/virtual": consts.GRAMMAR_INTENT_LANDING_PAGE_VIRTUAL_LESSONS, "lessons/lectures": consts.GRAMMAR_INTENT_LANDING_PAGE_LECTURES, "lessons/women": consts.GRAMMAR_INTENT_LANDING_PAGE_WOMEN_LESSONS, "lessons/rabash": consts.GRAMMAR_INTENT_LANDING_PAGE_RABASH_LESSONS, "lessons/series": consts.GRAMMAR_INTENT_LANDING_PAGE_LESSON_SERIES, "programs/main": consts.GRAMMAR_INTENT_LANDING_PAGE_PRORGRAMS, "programs/clips": consts.GRAMMAR_INTENT_LANDING_PAGE_CLIPS, "sources": consts.GRAMMAR_INTENT_LANDING_PAGE_LIBRARY, "events": consts.GRAMMAR_INTENT_LANDING_PAGE_CONVENTIONS, "events/conventions": consts.GRAMMAR_INTENT_LANDING_PAGE_CONVENTIONS, "events/holidays": consts.GRAMMAR_INTENT_LANDING_PAGE_HOLIDAYS, "events/unity-days": consts.GRAMMAR_INTENT_LANDING_PAGE_UNITY_DAYS, "events/friends-gatherings": consts.GRAMMAR_INTENT_LANDING_PAGE_FRIENDS_GATHERINGS, "events/meals": consts.GRAMMAR_INTENT_LANDING_PAGE_MEALS, "topics": consts.GRAMMAR_INTENT_LANDING_PAGE_TOPICS, "publications/blog": consts.GRAMMAR_INTENT_LANDING_PAGE_BLOG, "publications/twitter": consts.GRAMMAR_INTENT_LANDING_PAGE_TWITTER, "publications/articles": consts.GRAMMAR_INTENT_LANDING_PAGE_ARTICLES, "simple-mode": consts.GRAMMAR_INTENT_LANDING_PAGE_DOWNLOADS, "help": consts.GRAMMAR_INTENT_LANDING_PAGE_HELP, }
var SEARCH_QUALITY_BY_NAME = map[string]int{ "Good": SQ_GOOD, "Regular": SQ_REGULAR, "Unknown": SQ_UNKNOWN, "BadStructure": SQ_BAD_STRUCTURE, "NoExpectation": SQ_NO_EXPECTATION, "ServerError": SQ_SERVER_ERROR, }
var SEARCH_QUALITY_NAME = map[int]string{ SQ_GOOD: "Good", SQ_REGULAR: "Regular", SQ_UNKNOWN: "Unknown", SQ_BAD_STRUCTURE: "BadStructure", SQ_NO_EXPECTATION: "NoExpectation", SQ_SERVER_ERROR: "ServerError", }
Functions ¶
func CompareResults ¶ added in v0.8.0
Returns compare results classification constant.
func CreateGrammarIndex ¶ added in v1.6.6
func CsvToString ¶ added in v1.1.8
func DeleteGrammarIndex ¶ added in v1.6.6
func EvalResultDiffHtml ¶ added in v1.6.3
func EvalResultDiffHtml(resultDiff ResultDiff) (string, error)
func EvalResultsDiffsCount ¶ added in v1.6.3
func EvalResultsDiffsCount(evalSet []EvalQuery, expResults []EvalResult, baseResults []EvalResult) (int, error)
Assuming |expResults| and |baseResults| are ordered by |Order| field.
func EvalResultsDiffsHtml ¶ added in v1.6.3
func EvalResultsDiffsHtml(resultsDiffs ResultsDiffs) (string, error)
func EvalScrapeStreaming ¶ added in v1.6.3
func EvalScrapeStreaming(in chan EvalQuery, out chan EvalResult, serverUrl string, skipExpectations bool) error
In case of error, this function will close the |out| channel. In case of |in| closed, |out| will be closed after everything scraped.
func ExpectationToString ¶ added in v0.9.5
func ExpectationToString(e Expectation) string
func FilterValueToUid ¶ added in v0.9.5
func FoldGrammars ¶ added in v1.4.4
func FoldGrammarsV2 ¶ added in v1.6.6
func FoldGrammarsV2(first GrammarsV2, second GrammarsV2)
func GoodExpectations ¶ added in v0.9.5
func GoodExpectations(expectations []Expectation) int
func GrammarFilterVariablesMatch ¶ added in v1.6.6
func GrammarFilterVariablesMatch(intent string, variablesByPhrase VariablesByPhrase, cm cache.CacheManager)
func GrammarIndexName ¶ added in v1.6.6
func GrammarIndexNameForServing ¶ added in v1.6.8
func GrammarIndexNameFunc ¶ added in v1.6.8
func GrammarIndexNameFunc(indexDate string) es.IndexNameByLang
func GrammarVariablesMatch ¶ added in v1.6.6
func HitMatchesExpectation ¶ added in v0.9.5
func HitMatchesExpectation(hit *elastic.SearchHit, hitSource HitSource, e Expectation) bool
func HitSourcesEqual ¶ added in v1.6.3
func IndexGrammars ¶ added in v1.6.6
func IndexGrammars(esc *elastic.Client, indexDate string, grammars GrammarsV2, variables VariablesV2, cm cache.CacheManager) error
func LoadVariableTranslations ¶ added in v1.6.6
func MakeYearVariablesV2 ¶ added in v1.6.6
func NewFilteredResultsSearchRequest ¶ added in v1.10.0
func NewGammarPerculateRequest ¶ added in v1.10.0
func NewResultsSearchRequest ¶ added in v1.0.5
func NewResultsSearchRequest(options SearchRequestOptions) (*elastic.SearchRequest, error)
func NewResultsSearchRequests ¶ added in v1.0.5
func NewResultsSearchRequests(options SearchRequestOptions) ([]*elastic.SearchRequest, error)
func NewResultsSuggestGrammarV2CompletionRequest ¶ added in v1.6.6
func NewResultsSuggestRequest ¶ added in v1.0.5
func NewResultsSuggestRequests ¶ added in v1.0.5
func NewSuggestGammarV2Request ¶ added in v1.6.6
func PrintManyTokens ¶ added in v1.6.6
func PrintOriginalPhrase ¶ added in v1.6.6
func PrintToken ¶ added in v1.6.6
func PrintTokens ¶ added in v1.6.6
func ReadEvalSets ¶ added in v1.6.3
Return map from filename to query set.
func ResultsByExpectation ¶ added in v1.1.8
func ResultsByExpectation(queries []EvalQuery, results EvalResults) [][]string
func SplitPatterns ¶ added in v1.6.6
func SuggestionHasOptions ¶ added in v0.7.1
func SuggestionHasOptions(ss elastic.SearchSuggest) bool
func TokenNodesToString ¶ added in v1.5.2
func TokensMatch ¶ added in v1.5.2
func TokensSingleMatch ¶ added in v1.5.4
func VariablesAsString ¶ added in v1.6.6
Note the sort. It might be the case where order of vars important later on. In those cases we will not be able to sort the keys. We will have to keep order and distinguish between two different order cases.
func VariablesFromString ¶ added in v1.6.6
func VariablesMapToString ¶ added in v1.6.6
func WriteResults ¶ added in v0.9.5
func WriteResults(path string, queries []EvalQuery, results EvalResults) error
func WriteResultsByExpectation ¶ added in v0.9.5
func WriteResultsByExpectation(path string, queries []EvalQuery, results EvalResults) ([][]string, error)
func WriteToCsv ¶ added in v0.9.5
func WriteVsGoldenHTML ¶ added in v1.5.0
func YearScorePenalty ¶ added in v1.6.6
Types ¶
type ClassificationIntent ¶ added in v1.4.0
type ClassificationIntent struct { // Fields from result. ResultType string `json:"result_type"` MDB_UID string `json:"mdb_uid"` Title string `json:"title"` FullTitle string `json:"full_title"` // Intent fields. ContentType string `json:"content_type"` Exist bool `json:"exist"` Score *float64 `json:"score,omitempty"` Explanation elastic.SearchExplanation `json:"explanation,omitempty"` MaxScore *float64 `json:"max_score,omitempty"` MaxExplanation elastic.SearchExplanation `json:"max_explanation,omitempty"` }
type CreatedSearchClicks ¶ added in v0.8.3
type CreatedSearchClicks []SearchClick
func (CreatedSearchClicks) Len ¶ added in v0.8.3
func (csc CreatedSearchClicks) Len() int
func (CreatedSearchClicks) Less ¶ added in v0.8.3
func (csc CreatedSearchClicks) Less(i, j int) bool
func (CreatedSearchClicks) Swap ¶ added in v0.8.3
func (csc CreatedSearchClicks) Swap(i, j int)
type CreatedSearchLogs ¶ added in v0.8.3
type CreatedSearchLogs []SearchLog
func (CreatedSearchLogs) Len ¶ added in v0.8.3
func (csl CreatedSearchLogs) Len() int
func (CreatedSearchLogs) Less ¶ added in v0.8.3
func (csl CreatedSearchLogs) Less(i, j int) bool
func (CreatedSearchLogs) Swap ¶ added in v0.8.3
func (csl CreatedSearchLogs) Swap(i, j int)
type CrossIter ¶ added in v1.6.6
type CrossIter struct {
// contains filtered or unexported fields
}
func CreateCrossIter ¶ added in v1.6.6
type ESEngine ¶
type ESEngine struct { ExecutionTimeLog *TimeLogMap TokensCache *TokensCache // contains filtered or unexported fields }
func NewESEngine ¶
func NewESEngine(esc *elastic.Client, db *sql.DB, cache cache.CacheManager, tc *TokensCache, variables VariablesV2) *ESEngine
func (*ESEngine) AddIntentSecondRound ¶ added in v1.0.5
func (*ESEngine) AddIntents ¶ added in v0.8.9
func (*ESEngine) CombineResultsToSingleHit ¶ added in v1.6.3
func (*ESEngine) GetSuggestions ¶
func (*ESEngine) GetTypoSuggest ¶ added in v1.6.3
func (*ESEngine) IntentsToResults ¶ added in v0.9.5
func (*ESEngine) NativizeTweetsHitForClient ¶ added in v1.6.3
Moving data from InnerHits to Source (as marshaled json) (this is for client).
func (*ESEngine) SearchByFilterIntents ¶ added in v1.10.3
func (e *ESEngine) SearchByFilterIntents(filterIntents []Intent, filters map[string][]string, originalSearchTerm string, from int, size int, sortBy string, resultTypes []string, preference string, deb bool) (map[string][]FilteredSearchResult, error)
Search according to grammar based filter.
func (*ESEngine) SearchGrammars ¶ added in v1.4.4
func (*ESEngine) SearchGrammarsV2 ¶ added in v1.6.6
func (e *ESEngine) SearchGrammarsV2(query *Query, from int, size int, sortBy string, resultTypes []string, preference string) ([]Intent, []Intent, error)
Return: single hit intents, filtering intents
func (*ESEngine) SearchTweets ¶ added in v1.6.3
func (*ESEngine) SuggestGrammars ¶ added in v1.5.4
func (e *ESEngine) SuggestGrammars(query *Query) (map[string][]VariablesByPhrase, error)
func (*ESEngine) SuggestGrammarsV2 ¶ added in v1.6.6
func (*ESEngine) VariableMapToFilterValues ¶ added in v1.6.6
func (e *ESEngine) VariableMapToFilterValues(vMap map[string][]string, language string) []FilterValue
type ESManager ¶ added in v1.3.9
type ESManager struct {
// contains filtered or unexported fields
}
func MakeESManager ¶ added in v1.3.9
type EvalQuery ¶ added in v0.7.8
type EvalQuery struct { Language string `json:"language"` Query string `json:"query"` Weight float64 `json:"weight,omitempty"` Bucket string `json:"bucket,omitempty"` Expectations []Expectation `json:"expectations"` Comment string `json:"comment,omitempty"` }
func InitAndReadEvalSet ¶ added in v1.1.8
func ReadEvalDiffSet ¶ added in v1.6.3
type EvalResult ¶ added in v0.7.8
type EvalResult struct { SearchQuality []int `json:"search_quality"` Rank []int `json:"rank"` QueryResult QueryResult `json:"query_result"` Order int `json:"order,omitempty"` // contains filtered or unexported fields }
func EvalScrape ¶ added in v1.6.3
func EvalScrape(queries []EvalQuery, serverUrl string, skipExpectations bool) ([]EvalResult, error)
func EvaluateQuery ¶ added in v0.7.8
func EvaluateQuery(q EvalQuery, serverUrl string, skipExpectations bool) EvalResult
type EvalResults ¶ added in v0.7.8
type Expectation ¶ added in v0.8.0
type Expectation struct { Type int `json:"type"` Uid string `json:"uid,omitempty"` Filters []Filter `json:"filters,omitempty"` Source string `json:"source"` }
func ParseExpectation ¶ added in v0.8.0
func ParseExpectation(e string, db *sql.DB) Expectation
Parses expectation described by result URL and converts to type (collections or content_units) and uid. Examples: https://kabbalahmedia.info/he/programs/cu/AsNLozeK ==> (content_units, AsNLozeK) https://kabbalahmedia.info/he/programs/c/fLWpcUjQ ==> (collections , fLWpcUjQ) https://kabbalahmedia.info/he/lessons/series/c/XZoflItG ==> (collections , XZoflItG) https://kabbalahmedia.info/he/lessons?source=bs_L2jMWyce_kB3eD83I ==> (lessons, nil, source=bs_L2jMWyce_kB3eD83I) https://kabbalahmedia.info/he/programs?topic=g3ml0jum_1nyptSIo_RWqjxgkj ==> (programs, nil, topic=g3ml0jum_1nyptSIo_RWqjxgkj) https://kabbalahmedia.info/he/sources/kB3eD83I ==> (source, kB3eD83I) [latest]https://kabbalahmedia.info/he/lessons?source=bs_qMUUn22b_hFeGidcS ==> (content_units, SLQOALyt) [latest]https://kabbalahmedia.info/he/programs?topic=g3ml0jum_1nyptSIo_RWqjxgkj ==> (content_units, erZIsm86) [latest]https://kabbalahmedia.info/he/programs/c/zf4lLwyI ==> (content_units, orMKRcNk) All events sub pages and years: https://kabbalahmedia.info/he/events/meals https://kabbalahmedia.info/he/events/friends-gatherings https://kabbalahmedia.info/he/events?year=2013
type FileVariable ¶ added in v1.6.6
type FileVariable struct {
// contains filtered or unexported fields
}
func (FileVariable) Match ¶ added in v1.6.6
func (fv FileVariable) Match(token *TokenNode, variableToken *TokenNode, matchPrefixes bool, variables map[string]*Variable) (bool, []VariableValue, []*TokenNode, error)
func (FileVariable) Name ¶ added in v1.6.6
func (fv FileVariable) Name() string
func (FileVariable) VariableToPhrases ¶ added in v1.6.6
func (fv FileVariable) VariableToPhrases(prefix, suffix string, variables map[string]*Variable) []*PhrasesWithOrigin
type FilterValue ¶ added in v1.6.6
type FilterValue struct { Name string `json:"name,omitempty"` Value string `json:"value,omitempty"` Origin string `json:"origin,omitempty"` OriginFull string `json:"origin_full,omitempty"` }
func VariableValuesToFilterValues ¶ added in v1.6.6
func VariableValuesToFilterValues(values []VariableValue) []FilterValue
type FilteredSearchResult ¶ added in v1.10.0
type Grammar ¶ added in v1.4.4
type Grammar struct { HitType string Language string Intent string Patterns [][]*TokenNode Filters map[string][]string Esc *elastic.Client Variables VariablesByName }
func (*Grammar) SearchGrammar ¶ added in v1.4.4
func (g *Grammar) SearchGrammar(query *Query, tc *TokensCache, cm cache.CacheManager) (*Intent, error)
func (*Grammar) SuggestGrammar ¶ added in v1.5.4
func (g *Grammar) SuggestGrammar(query *Query, tc *TokensCache, cm cache.CacheManager) (VariablesByPhrase, error)
type GrammarIntent ¶ added in v1.4.4
type GrammarIntent struct { LandingPage string `json:"landing_page,omitempty"` FilterValues []FilterValue `json:"filter_values,omitempty"` Score float64 `json:"score,omitempty"` Explanation *elastic.SearchExplanation `json:"explanation,omitempty"` SingleHit *elastic.SearchHit `json:"single_hit,omitempty"` SingleHitMdbUid *string `json:"single_hit_mdb_uid,omitempty"` }
type GrammarRule ¶ added in v1.6.6
type GrammarRuleWithPercolatorQuery ¶ added in v1.10.0
type GrammarRuleWithPercolatorQuery struct { GrammarRule GrammarRule `json:"grammar_rule"` Query interface{} `json:"query"` SearchText string `json:"search_text"` }
type Grammars ¶ added in v1.4.4
func MakeGrammars ¶ added in v1.4.4
func MakeGrammars(grammarsDir string, esc *elastic.Client, tc *TokensCache, variables VariablesByLang) (Grammars, error)
func ReadGrammarFile ¶ added in v1.4.4
func ReadGrammarFile(grammarFile string, esc *elastic.Client, tc *TokensCache, variables VariablesByLang) (Grammars, error)
type GrammarsV2 ¶ added in v1.6.6
Map from lang => intent => Grammar
func MakeGrammarsV2 ¶ added in v1.6.6
func MakeGrammarsV2(grammarsDir string) (GrammarsV2, error)
func ReadGrammarFileV2 ¶ added in v1.6.6
func ReadGrammarFileV2(grammarFile string) (GrammarsV2, error)
type HitSource ¶ added in v0.9.5
type HitSource struct { MdbUid string `json:"mdb_uid"` ResultType string `json:"result_type"` LandingPage string `json:"landing_page"` Title string `json:"title,omitempty"` Content string `json:"content,omitempty"` CarrouselHitSources []HitSource `json:"carrousel,omitempty"` ContentType string `json:"content_type,omitempty"` Score float64 `json:"score,omitempty"` }
type Loss ¶ added in v0.8.9
type Loss struct { Expectation Expectation `json:"expectation,omitempty"` Query EvalQuery `json:"query,omitempty"` Unique float64 `json:"unique,omitempty"` Weighted float64 `json:"weighted,omitempty"` }
type OriginalTokenNode ¶ added in v1.5.4
type OriginalTokenNode struct { OriginalWholePhrase *string SkippedPrefix *Span // Stopwords before this token that were skipped. OriginalPhrase string // Original string that was tokenized. SkippedSuffix *Span // Will be set only for IsEnd = true nodes. TokenNode *TokenNode Parents []*OriginalTokenNode Children []*OriginalTokenNode }
func (*OriginalTokenNode) OriginalFullPhraseToString ¶ added in v1.5.4
func (otn *OriginalTokenNode) OriginalFullPhraseToString() string
func (*OriginalTokenNode) OriginalVariablePrefixToString ¶ added in v1.6.6
func (otn *OriginalTokenNode) OriginalVariablePrefixToString() string
func (*OriginalTokenNode) OriginalVariableToString ¶ added in v1.6.6
func (otn *OriginalTokenNode) OriginalVariableToString() string
func (*OriginalTokenNode) SkippedPrefixToString ¶ added in v1.5.4
func (otn *OriginalTokenNode) SkippedPrefixToString() string
func (*OriginalTokenNode) SkippedSuffixToString ¶ added in v1.5.4
func (otn *OriginalTokenNode) SkippedSuffixToString() string
type PhrasesByVariables ¶ added in v1.6.6
type PhrasesByVariables struct { P []*PhrasesWithOrigin M map[string][]string }
type PhrasesWithOrigin ¶ added in v1.5.4
type PhrasesWithOrigin struct { VariableValues []VariableValue // contains filtered or unexported fields }
func CopyPhrasesWithOrigin ¶ added in v1.6.6
func CopyPhrasesWithOrigin(p []*PhrasesWithOrigin) []*PhrasesWithOrigin
func MakePhrasesWithOrigin ¶ added in v1.6.6
func MakePhrasesWithOrigin(prefix, phrase, suffix, token string) *PhrasesWithOrigin
func MakeVariablePhraseWithOrigin ¶ added in v1.6.6
func MakeVariablePhraseWithOrigin(variable, prefix, suffix string) *PhrasesWithOrigin
func OriginalTokenNodesToPhrases ¶ added in v1.5.4
func OriginalTokenNodesToPhrases(otns []*OriginalTokenNode, variables map[string]*Variable, reduceVariables bool) []*PhrasesWithOrigin
func TokenNodesToPhrases ¶ added in v1.5.2
func TokenNodesToPhrases(root []*TokenNode, variables map[string]*Variable, reduceVariables bool) []*PhrasesWithOrigin
func (*PhrasesWithOrigin) Invalidate ¶ added in v1.6.6
func (p *PhrasesWithOrigin) Invalidate()
func (*PhrasesWithOrigin) Join ¶ added in v1.5.4
func (p *PhrasesWithOrigin) Join(s string) string
func (*PhrasesWithOrigin) OriginalJoin ¶ added in v1.5.4
func (p *PhrasesWithOrigin) OriginalJoin() string
func (*PhrasesWithOrigin) Reduce ¶ added in v1.6.6
func (p *PhrasesWithOrigin) Reduce(variableName, variableValue, prefix, suffix string)
func (*PhrasesWithOrigin) ToString ¶ added in v1.5.4
func (p *PhrasesWithOrigin) ToString() string
func (*PhrasesWithOrigin) VariableValuesJoin ¶ added in v1.6.6
func (p *PhrasesWithOrigin) VariableValuesJoin() string
func (*PhrasesWithOrigin) VariablesMap ¶ added in v1.6.6
func (pwo *PhrasesWithOrigin) VariablesMap() (map[string][]string, string)
type Query ¶
type Query struct { Term string `json:"term,omitempty"` ExactTerms []string `json:"exact_terms,omitempty"` Original string `json:"original,omitempty"` Filters map[string][]string `json:"filters,omitempty"` LanguageOrder []string `json:"language_order,omitempty"` Deb bool `json:"deb,omitempty"` Intents []Intent `json:"intents,omitempty"` }
func ParseQuery ¶ added in v1.4.4
Parses query and extracts terms and filters.
func (*Query) ToFullSimpleString ¶ added in v1.1.9
func (*Query) ToSimpleString ¶ added in v1.1.9
type QueryResult ¶ added in v0.8.9
type ResultDiff ¶ added in v1.6.3
type ResultDiff struct { ErrorStr string `json:"error_str"` Query string `json:"query"` HitsDiffs []HitDiff `json:"hits_diffs"` }
func EvalResultDiff ¶ added in v1.6.3
func EvalResultDiff(evalQuery EvalQuery, expResult EvalResult, baseResult EvalResult) (ResultDiff, error)
type ResultsDiffs ¶ added in v1.6.3
type ResultsDiffs struct { ErrorStr string `json:"error_str"` ResultsDiffs []ResultDiff `json:"results_diffs"` Diffs int `json:"diffs"` Scraped int `json:"scraped"` DiffsWeight float64 `json:"diffs_weight"` TotalWeight float64 `json:"total_weight"` }
func EvalQuerySetDiff ¶ added in v1.6.3
func EvalQuerySetDiff(evalSet []EvalQuery, baseServerUrl, expServerUrl string, diffsLimit int32) (ResultsDiffs, error)
If |diffsLimit| > 0 will limit the diff to constant number of queries.
func EvalResultsDiffs ¶ added in v1.6.3
func EvalResultsDiffs(evalSet []EvalQuery, expResults []EvalResult, baseResults []EvalResult) (ResultsDiffs, error)
func EvalSearchDataQuerySetsDiff ¶ added in v1.6.3
func EvalSearchDataQuerySetsDiff(language, baseServerUrl, expServerUrl string, diffsLimit int32) ([]ResultsDiffs, error)
type SearchClick ¶ added in v0.8.0
type SearchLog ¶ added in v0.7.7
type SearchLog struct { SearchId string `json:"search_id"` Created time.Time `json:"created"` LogType string `json:"log_type"` Query Query `json:"query"` QueryResult interface{} `json:"query_result,omitempty"` Error interface{} `json:"error,omitempty"` SortBy string `json:"sort_by,omitempty"` From uint64 `json:"from,omitempty"` Size uint64 `json:"size,omitempty"` Suggestion string `json:"suggestion,omitempty"` ExecutionTimeLog []TimeLog `json:"execution_time_log,omitempty"` }
type SearchLogger ¶ added in v0.7.7
type SearchLogger struct {
// contains filtered or unexported fields
}
func MakeSearchLogger ¶ added in v0.7.7
func MakeSearchLogger(esManager *ESManager) *SearchLogger
func (*SearchLogger) GetAllClicks ¶ added in v0.8.3
func (searchLogger *SearchLogger) GetAllClicks() ([]SearchClick, error)
func (*SearchLogger) GetAllQueries ¶ added in v0.7.8
func (searchLogger *SearchLogger) GetAllQueries(s *elastic.SliceQuery) ([]SearchLog, error)
func (*SearchLogger) GetLattestQueries ¶ added in v1.6.3
func (searchLogger *SearchLogger) GetLattestQueries(s *elastic.SliceQuery, gte null.String, ascending null.Bool) ([]SearchLog, error)
func (*SearchLogger) LogSearch ¶ added in v0.7.7
func (searchLogger *SearchLogger) LogSearch(query Query, sortBy string, from int, size int, searchId string, suggestion string, res *QueryResult, executionTimeLog *TimeLogMap) error
func (*SearchLogger) LogSearchError ¶ added in v0.7.7
func (searchLogger *SearchLogger) LogSearchError(query Query, sortBy string, from int, size int, searchId string, suggestion string, searchErr interface{}, executionTimeLog *TimeLogMap) error
type SearchRequestOptions ¶ added in v1.0.5
type SearchRequestOptions struct { // If not nil, set how long a search is allowed to take, e.g. "1s" or "500ms". Note: Not always respected by ES. Timeout *string // contains filtered or unexported fields }
type TimeLogMap ¶ added in v1.3.9
type TimeLogMap struct {
// contains filtered or unexported fields
}
func NewTimeLogMap ¶ added in v1.3.9
func NewTimeLogMap() *TimeLogMap
func (*TimeLogMap) Load ¶ added in v1.3.9
func (c *TimeLogMap) Load(key string) (time.Duration, bool)
type TokenNode ¶ added in v1.5.2
type TokenNode struct { Token Token IsEnd bool Parents []*TokenNode Children []*TokenNode // May be several original phrases per token from several sources that were merged. OriginalTokenNodes []*OriginalTokenNode // Caches phrases with origin. Phrases []*PhrasesWithOrigin }
func MakeTokensFromPhrase ¶ added in v1.5.2
func MakeTokensFromPhrase(phrase string, lang string, esc *elastic.Client, tc *TokensCache) ([]*TokenNode, error)
type TokensCache ¶ added in v1.5.4
type TokensCache struct {
// contains filtered or unexported fields
}
func MakeTokensCache ¶ added in v1.5.4
func MakeTokensCache(size int) *TokensCache
func (*TokensCache) Get ¶ added in v1.5.4
func (tc *TokensCache) Get(phrase string, lang string) []*TokenNode
type TokensCacheElement ¶ added in v1.5.4
type Translations ¶ added in v1.6.6
Map from variable => language => value => Tokens
func LoadVariablesTranslations ¶ added in v1.6.6
func LoadVariablesTranslations(variablesDir string, esc *elastic.Client, tc *TokensCache) (Translations, error)
type TranslationsV2 ¶ added in v1.6.6
Translations language => value => phrases
func GeneratePositionVariables ¶ added in v1.12.0
func GeneratePositionVariables(db *sql.DB) (TranslationsV2, error)
func LoadHolidayTranslationsFromDB ¶ added in v1.7.5
func LoadHolidayTranslationsFromDB(db *sql.DB) (TranslationsV2, error)
func LoadProgramNameTranslationsFromDB ¶ added in v1.12.0
func LoadProgramNameTranslationsFromDB(db *sql.DB) (TranslationsV2, error)
func LoadSourceNameTranslationsFromDB ¶ added in v1.11.0
func LoadSourceNameTranslationsFromDB(db *sql.DB) (TranslationsV2, error)
func LoadVariableTranslationsFromFile ¶ added in v1.7.5
func LoadVariableTranslationsFromFile(variableFile string, variableName string) (TranslationsV2, error)
type Variable ¶ added in v1.6.6
type Variable interface { Name() string Match(token *TokenNode, variableToken *TokenNode, matchPrefixes bool, variables map[string]*Variable) (bool, []VariableValue, []*TokenNode, error) VariableToPhrases(prefix, suffix string, variables map[string]*Variable) []*PhrasesWithOrigin }
func MakeFileVariable ¶ added in v1.6.6
func MakeFileVariable(name string, lang string, translations Translations) Variable
func MakeYearVariable ¶ added in v1.6.6
func MakeYearVariable() Variable
type VariableValue ¶ added in v1.6.6
type VariableValue struct { Name string // Variable name. Value string // Variable value. Tokenized []string // Tokenized phrase. Origin string // Original phrase. OriginFull string // Original phrase with prefix and suffix. }
func MakeTextVariableValue ¶ added in v1.6.6
func MakeTextVariableValue(prefix, phrase, suffix, token string) VariableValue
func MakeVariableValue ¶ added in v1.6.6
func MakeVariableValue(variable, prefix, phrase, suffix, token, value string) VariableValue
type VariablesByLang ¶ added in v1.6.6
type VariablesByLang = map[string]VariablesByName
func MakeVariables ¶ added in v1.6.6
func MakeVariables(variablesDir string, esc *elastic.Client, tc *TokensCache) (VariablesByLang, error)
type VariablesByName ¶ added in v1.6.6
Map from language => name => variable.
type VariablesByPhrase ¶ added in v1.6.6
Map from Original Full Phrase => $Var => values
func TokensSearch ¶ added in v1.5.4
func TokensSearch(a []*TokenNode, b [][]*TokenNode, variables map[string]*Variable) (VariablesByPhrase, error)
Searches tokens |a| inside tokens |b|, returns the matching part. Can be optimized? Current complexity is O(|a|^2 * |b|^2), where |a| is nubmer of tokens in the whole graph of |a|.
func TokensSingleSearch ¶ added in v1.5.4
func TokensSingleSearchTest ¶ added in v1.6.6
type VariablesV2 ¶ added in v1.6.6
type VariablesV2 = map[string]TranslationsV2
Map from variable => language => value => phrases
func LoadVariablesTranslationsV2 ¶ added in v1.6.6
func LoadVariablesTranslationsV2(variablesDir string) (VariablesV2, error)
func MakeVariablesV2 ¶ added in v1.6.6
func MakeVariablesV2(variablesDir string) (VariablesV2, error)
type YearVariable ¶ added in v1.6.6
type YearVariable struct {
// contains filtered or unexported fields
}
func (YearVariable) Match ¶ added in v1.6.6
func (yv YearVariable) Match(token *TokenNode, variableToken *TokenNode, matchPrefixes bool, variables map[string]*Variable) (bool, []VariableValue, []*TokenNode, error)
func (YearVariable) Name ¶ added in v1.6.6
func (yv YearVariable) Name() string
func (YearVariable) VariableToPhrases ¶ added in v1.6.6
func (yv YearVariable) VariableToPhrases(prefix, suffix string, variables map[string]*Variable) []*PhrasesWithOrigin
Source Files ¶
- common.go
- elastic_search_manager.go
- engine.go
- file_variable.go
- grammar.go
- grammar_engine.go
- grammar_query.go
- grammar_v2.go
- grammar_v2_engine.go
- grammar_v2_index.go
- grammar_variables_matcher.go
- intent_engine.go
- models.go
- quality_eval.go
- query.go
- search_logger.go
- token.go
- token_internal.go
- tweets_engine.go
- typo_suggest_engine.go
- variable.go
- variable_v2.go
- year.go