Documentation
¶
Index ¶
- Constants
- Variables
- func CompareResults(base int, exp int) int
- func ExpectationToString(e Expectation) string
- func FilterValueToUid(value string) string
- func GetCollectionsSearchRequests(query Query, sortBy string, from int, size int, preference string) []*elastic.SearchRequest
- func GetContentUnitsSearchRequests(query Query, sortBy string, from int, size int, preference string) []*elastic.SearchRequest
- func GetSourcesSearchRequests(query Query, from int, size int, preference string) []*elastic.SearchRequest
- func GoodExpectations(expectations []Expectation) int
- func HitMatchesExpectation(hit *elastic.SearchHit, hitSource HitSource, e Expectation) bool
- func SourcesIntentRequest(query Query, language string, preference string) *elastic.SearchRequest
- func SuggestionHasOptions(ss elastic.SearchSuggest) bool
- func TagsIntentRequest(query Query, language string, preference string) *elastic.SearchRequest
- func WriteResults(path string, queries []EvalQuery, results EvalResults) error
- func WriteResultsByExpectation(path string, queries []EvalQuery, results EvalResults) error
- func WriteToCsv(path string, records [][]string) error
- type CreatedSearchClicks
- type CreatedSearchLogs
- type ESEngine
- func (e *ESEngine) AddClassificationIntentSecondRound(h *elastic.SearchHit, intent Intent, query Query) (error, *Intent, *Query)
- func (e *ESEngine) AddIntents(query *Query, preference string) 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) (interface{}, error)
- func (e *ESEngine) IntentsToResults(query *Query) (error, map[string]*elastic.SearchResult)
- type Engine
- type EvalQuery
- type EvalResult
- type EvalResults
- type Expectation
- type Filter
- type HitSource
- type Intent
- type IntentRequestFunc
- type Loss
- type Query
- type QueryResult
- type SearchClick
- type SearchLog
- type SearchLogger
- func (searchLogger *SearchLogger) GetAllClicks() ([]SearchClick, error)
- func (searchLogger *SearchLogger) GetAllQueries() ([]SearchLog, error)
- func (searchLogger *SearchLogger) LogClick(mdbUid string, index string, indexType 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
Constants ¶
const ( EVAL_SET_EXPECTATION_FIRST_COLUMN = 4 EVAL_SET_EXPECTATION_LAST_COLUMN = 8 )
const ( SQ_SERVER_ERROR = iota SQ_NO_EXPECTATION = 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_CONTENT_UNITS = iota ET_COLLECTIONS = iota ET_LESSONS = iota ET_PROGRAMS = iota ET_SOURCES = iota ET_EMPTY = iota ET_FAILED_PARSE = iota ET_BAD_STRUCTURE = iota )
const ( FILTER_NAME_SOURCE = "source" FILTER_NAME_TOPIC = "topic" )
Variables ¶
var COMPARE_RESULTS_NAME = map[int]string{ CR_WIN: "Win", CR_LOSS: "Loss", CR_SAME: "Same", CR_ERROR: "Error", }
var EXPECTATION_HIT_TYPE = map[int]string{ ET_CONTENT_UNITS: "content_units", ET_COLLECTIONS: "collections", ET_LESSONS: consts.INTENT_HIT_TYPE_LESSONS, ET_PROGRAMS: consts.INTENT_HIT_TYPE_PROGRAMS, ET_SOURCES: "sources", }
var EXPECTATION_TO_NAME = map[int]string{ ET_CONTENT_UNITS: "cu", ET_COLLECTIONS: "c", ET_LESSONS: "l", ET_PROGRAMS: "p", ET_SOURCES: "s", ET_EMPTY: "e", ET_FAILED_PARSE: "fp", ET_BAD_STRUCTURE: "bs", }
var EXPECTATION_URL_PATH = map[int]string{ ET_CONTENT_UNITS: "cu", ET_COLLECTIONS: "c", ET_LESSONS: "lessons", ET_PROGRAMS: "programs", ET_SOURCES: "sources", }
var GOOD_EXPECTATION = map[int]bool{ ET_CONTENT_UNITS: true, ET_COLLECTIONS: true, ET_LESSONS: true, ET_PROGRAMS: true, ET_SOURCES: true, ET_EMPTY: false, ET_FAILED_PARSE: false, ET_BAD_STRUCTURE: false, }
var SEARCH_QUALITY_NAME = map[int]string{ SQ_GOOD: "Good", SQ_REGULAR: "Regular", SQ_UNKNOWN: "Unknown", SQ_NO_EXPECTATION: "NoExpectation", SQ_SERVER_ERROR: "ServerError", }
Functions ¶
func CompareResults ¶ added in v0.8.0
Returns compare results classification constant.
func ExpectationToString ¶ added in v0.9.5
func ExpectationToString(e Expectation) string
func FilterValueToUid ¶ added in v0.9.5
func GetCollectionsSearchRequests ¶ added in v0.8.9
func GetContentUnitsSearchRequests ¶ added in v0.8.9
func GetSourcesSearchRequests ¶ added in v0.8.9
func GoodExpectations ¶ added in v0.9.5
func GoodExpectations(expectations []Expectation) int
func HitMatchesExpectation ¶ added in v0.9.5
func HitMatchesExpectation(hit *elastic.SearchHit, hitSource HitSource, e Expectation) bool
func SourcesIntentRequest ¶ added in v0.8.9
func SuggestionHasOptions ¶ added in v0.7.1
func SuggestionHasOptions(ss elastic.SearchSuggest) bool
func TagsIntentRequest ¶ added in v0.8.9
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) error
func WriteToCsv ¶ added in v0.9.5
Types ¶
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 ESEngine ¶
type ESEngine struct {
// contains filtered or unexported fields
}
func NewESEngine ¶
func NewESEngine(esc *elastic.Client, db *sql.DB, cache cache.CacheManager) *ESEngine
func (*ESEngine) AddClassificationIntentSecondRound ¶ added in v0.8.9
func (*ESEngine) AddIntents ¶ added in v0.8.9
func (*ESEngine) GetSuggestions ¶
type EvalQuery ¶ added in v0.7.8
type EvalQuery struct { Language string `json:"language"` Query string `json:"query"` Weight uint64 `json:"weight,omitempty"` Bucket string `json:"bucket,omitempty"` Expectations []Expectation `json:"expectations"` Comment string `json:"comment,omitempty"` }
func ReadEvalSet ¶ added in v0.7.8
type EvalResult ¶ added in v0.7.8
type EvalResult struct { SearchQuality []int `json:"search_quality"` Rank []int `json:"rank"` // contains filtered or unexported fields }
func EvaluateQuery ¶ added in v0.7.8
func EvaluateQuery(q EvalQuery, serverUrl string) 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) Expectation
Parses expectation described by result URL and converts to type (collections or content_units) and uid. Examples: https://archive.kbb1.com/he/programs/cu/AsNLozeK ==> (content_units, AsNLozeK) https://archive.kbb1.com/he/programs/c/fLWpcUjQ ==> (collections , fLWpcUjQ) https://archive.kbb1.com/he/lessons?source=bs_L2jMWyce_kB3eD83I ==> (lessons, nil, source=bs_L2jMWyce_kB3eD83I) https://archive.kbb1.com/he/programs?topic=g3ml0jum_1nyptSIo_RWqjxgkj ==> (programs, nil, topic=g3ml0jum_1nyptSIo_RWqjxgkj) https://archive.kbb1.com/he/sources/kB3eD83I ==> (sources, kB3eD83I) All events sub pages and years: https://archive.kbb1.com/he/events/meals https://archive.kbb1.com/he/events/friends-gatherings https://archive.kbb1.com/he/events?year=2013
type IntentRequestFunc ¶ added in v0.8.9
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 QueryResult ¶ added in v0.8.9
type QueryResult struct { SearchResult *elastic.SearchResult `json:"search_result,omitempty"` Intents []Intent `json:"intents,omitempty"` }
type SearchClick ¶ added in v0.8.0
type SearchLog ¶ added in v0.7.7
type SearchLog struct { Created time.Time `json:"created",omitempty` 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"` Size uint64 `json:"size,omitempty"` SearchId string `json:"search_id"` // Deprecated field. Results interface{} `json:"results,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(esc *elastic.Client) *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() ([]SearchLog, error)
func (*SearchLogger) LogSearch ¶ added in v0.7.7
func (searchLogger *SearchLogger) LogSearch(query Query, sortBy string, from int, size int, searchId string, res *QueryResult) error