model

package
v0.0.0-...-83adff0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MngAssetTypeDB .
	MngAssetTypeDB = 1
	// MngAssetTypeES .
	MngAssetTypeES = 2
	// MngAssetTypeDatabus .
	MngAssetTypeDatabus = 3
	// MngAssetTypeTable .
	MngAssetTypeTable = 4
)
View Source
const (
	// UserSearchDB bili_search.
	UserSearchDB = "bili_search"
	// DBDsnFormat .
	DBDsnFormat = "%s:%s@tcp(%s:%s)/%s?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8mb4,utf8"
)

Variables

View Source
var (
	// QueryModeBasic completely using basic query & nested .
	QueryModeBasic = 1
	// QueryModeExtra write some extra conditions under basic query .
	QueryModeExtra = 2

	// EnhancedModeGroupBy group by .
	EnhancedModeGroupBy = "group_by"
	// EnhancedModeSum sum from a filed .
	EnhancedModeSum = "sum"
	// EnhancedModeCollapse collapse .
	EnhancedModeCollapse = "collapse"
	// EnhancedModeDistinct distinct .
	EnhancedModeDistinct = "distinct"
	// EnhancedModeDistinctCount distinct .
	EnhancedModeDistinctCount = "distinct_count"
	// EnhancedModeGroupBySum group by sum .
	EnhancedModeGroupBySum = "group_by_sum"
	// EnhancedModeGroupByTop top hits .
	EnhancedModeGroupByTop = "group_by_tophits"

	// LikeLevelHigh high level .
	LikeLevelHigh = "high"
	// LikeLevelMiddel middle level .
	LikeLevelMiddel = "middle"
	// LikeLevelLow low level .
	LikeLevelLow = "low"

	// QueryConf 自定义部分
	QueryConf = map[string]*QueryConfDetail{
		"archive_video_score":     {ESCluster: "ssd_archive", IndexPrefix: "archive_video", MaxIndicesNum: 1, QueryMode: QueryModeExtra},
		"archive_score":           {ESCluster: "ssd_archive", IndexPrefix: "archive", MaxIndicesNum: 1, QueryMode: QueryModeExtra},
		"task_qa_random":          {ESCluster: "internalPublic", IndexPrefix: "task_qa", MaxIndicesNum: 1, QueryMode: QueryModeExtra},
		"esports_contests_date":   {ESCluster: "pcie_pub_out01", IndexPrefix: "esports_contests_map", MaxIndicesNum: 1, QueryMode: QueryModeExtra},
		"creative_archive_search": {ESCluster: "pcie_pub_out01", IndexPrefix: "creative_archive", MaxIndicesNum: 1, QueryMode: QueryModeExtra},
		"creative_archive_staff":  {ESCluster: "pcie_pub_out02", IndexPrefix: "creative_archive", IndexID: "%d,id", IndexType: "base", MaxIndicesNum: 1, QueryMode: QueryModeExtra},
		"creative_archive_apply":  {ESCluster: "pcie_pub_out02", IndexPrefix: "creative_archive", MaxIndicesNum: 1, QueryMode: QueryModeExtra},
		"dm_history":              {ESCluster: "dmout", IndexPrefix: "dm_search", MaxIndicesNum: 1, QueryMode: QueryModeExtra},
	}

	// PermConf 权限业务
	PermConf = map[string]map[string]string{
		"star":     {"ops_log_billions": "true"},
		"scroll":   {"dm_search": "true"},
		"oht":      {"creative_reply": "true", "creative_reply_isreport": "true", "esports": "true"},
		"es_cache": {"comics_firebird": "true", "pgc_media": "true", "pgc_season": "true"},
	}
)
View Source
var LogAuditDefaultMapping = map[string]string{
	"uname":      "string",
	"uid":        "string",
	"type":       "string",
	"oid":        "string",
	"action":     "string",
	"ctime":      "time",
	"int_0":      "int",
	"int_1":      "int",
	"int_2":      "int",
	"str_0":      "string",
	"str_1":      "string",
	"str_2":      "string",
	"extra_data": "string",
}

LogAuditDefaultMapping .

View Source
var LogUserActionDefaultMapping = map[string]string{
	"mid":        "string",
	"platform":   "string",
	"build":      "string",
	"buvid":      "string",
	"type":       "string",
	"oid":        "string",
	"action":     "string",
	"ip":         "string",
	"ctime":      "time",
	"int_0":      "int",
	"int_1":      "int",
	"int_2":      "int",
	"str_0":      "string",
	"str_1":      "string",
	"str_2":      "string",
	"extra_data": "string",
}

LogUserActionDefaultMapping .

Functions

This section is empty.

Types

type ArchiveCheckParams

type ArchiveCheckParams struct {
	Bsp          *BasicSearchParams
	Aids         []int64 `form:"aids,split" params:"aids"`
	TypeIds      []int64 `form:"typeids,split" params:"typeids"`
	States       []int64 `form:"states,split" params:"states"`
	Attrs        []int64 `form:"attrs,split" params:"attrs"`
	DurationFrom int64   `form:"duration_from" params:"duration_from"`
	DurationTo   int64   `form:"duration_to" params:"duration_to"`
	Mids         []int64 `form:"mids,split" params:"mids"`
	MidFrom      int64   `form:"mid_from" params:"mid_from"`
	MidTo        int64   `form:"mid_to" params:"mid_to"`
	AllKW        int     `form:"all_kw" params:"all_kw" default:"0"`
	TimeFrom     string  `form:"time_from" params:"time_from"`
	TimeTo       string  `form:"time_to" params:"time_to"`
	Time         string  `form:"time" params:"time"`
	FromIP       string  `form:"from_ip" params:"from_ip"`
}

ArchiveCheckParams search params.

type ArchiveCommerce

type ArchiveCommerce struct {
	Bsp        *BasicSearchParams
	Ids        []string `form:"ids,split" params:"ids"`
	PTypeIds   []string `form:"ptypeids,split" params:"ptypeids"`
	TypeIds    []string `form:"typeids,split" params:"typeids"`
	Mids       []string `form:"mids,split" params:"mids"`
	States     []string `form:"states,split" params:"states"`
	Copyrights []string `form:"copyrights,split" params:"copyrights"`
	OrderIds   []string `form:"order_ids,split" params:"order_ids"`
	// 逻辑判断
	Action     string `form:"action" params:"action"`                        // 获取一级分区列表、等其他定制查询
	IsOrder    int    `form:"is_order" params:"is_order" default:"-1"`       //是否商单
	IsOriginal int    `form:"is_original" params:"is_original" default:"-1"` //是否原创
}

ArchiveCommerce .

type BasicMNGSearchParams

type BasicMNGSearchParams struct {
	Order string `form:"order" params:"order"`
	Sort  string `form:"sort" params:"sort" default:"desc"`
	Pn    int    `form:"pn" params:"pn;Range(1,5000)" default:"1"`
	Ps    int    `form:"ps" params:"ps;Range(1,1000)" default:"10"`
}

BasicMNGSearchParams .

type BasicSearchParams

type BasicSearchParams struct {
	AppID      string   `form:"appid" params:"appid"`
	Pattern    string   `form:"pattern" params:"pattern" default:"equal"` //关键字匹配模式,完成匹配:equal,模糊查询:like
	KW         string   `form:"kw" params:"kw"`
	KwFields   []string `form:"kw_fields,split" params:"kw_fields"`
	KWs        []string `form:"kws,split" params:"kws"` //关键词组,用于AND OR连接
	Order      []string `form:"order,split" params:"order"`
	Sort       []string `form:"sort,split" params:"sort" default:"desc"`
	Pn         int      `form:"pn" params:"pn;Range(1,5000)" default:"1"`
	Ps         int      `form:"ps" params:"ps;Range(1,1000)" default:"10"`
	Highlight  bool     `form:"highlight" params:"highlight" default:"false"`
	ScoreFirst bool     `form:"score_first" params:"score_first" default:"true"`
	Debug      bool     `form:"debug" params:"debug"`
	Source     []string
}

BasicSearchParams (deprecated).

type BasicUpdateParams

type BasicUpdateParams struct {
	AppID string
}

BasicUpdateParams (deprecated).

type Business

type Business struct {
	ID                int
	AppID             string
	Name              string
	AdditionalMapping string
	Mapping           map[string]string
	IndexFormat       string
	IndexCluster      string
	PermissionPoint   string
}

Business .

type CopyRight struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	OName       string `json:"oname"`
	AkaNames    string `json:"aka_names"`
	Level       string `json:"level"`
	AVoid       string `json:"avoid"`
	Plan        string `json:"plan"`
	Description string `json:"description"`
	URL         string `json:"url"`
}

CopyRight .

func (*CopyRight) IndexID

func (c *CopyRight) IndexID() string

IndexID .

func (*CopyRight) IndexName

func (c *CopyRight) IndexName() string

IndexName .

func (*CopyRight) IndexType

func (c *CopyRight) IndexType() string

IndexType .

type ES

type ES struct {
	Addr string
}

ES .

type GFAsset

type GFAsset struct {
	ID          int64  `json:"id"`
	Type        string `json:"type"`
	Name        string `json:"name"`
	DSN         string `json:"dsn"`
	DB          string `json:"db"`
	Regex       string `json:"relex"`
	Fields      string `json:"fields"`
	Description string `json:"description"`
	State       int8   `json:"state"`
}

GFAsset .

type GFBusiness

type GFBusiness struct {
	ID           int64  `json:"id"`
	PID          int64  `json:"pid"`
	Name         string `json:"name"`
	DataConf     string `json:"data_conf"`
	IndexConf    string `json:"index_conf"`
	BusinessConf string `json:"business_conf"`
	Description  string `json:"description"`
	State        int8   `json:"state"`
	Mtime        string `json:"mtime"`
}

GFBusiness .

type IPData

type IPData struct {
	Code int `json:"code"`
	Data map[string]struct {
		Country  string `json:"country"`
		Province string `json:"province"`
		City     string `json:"city"`
		Isp      string `json:"isp"`
	}
}

IPData .

type LogParams

type LogParams struct {
	Bsp       *BasicSearchParams
	Business  int    `form:"business" params:"business"`
	CTimeFrom string `form:"ctime_from" params:"ctime_from"`
	CTimeTo   string `form:"ctime_to" params:"ctime_to"`
}

LogParams .

type MapData

type MapData map[string]interface{}

MapData .

func (MapData) NumberToInt64

func (m MapData) NumberToInt64() (err error)

func (MapData) StrID

func (m MapData) StrID(indexID string) string

StrID .

type MngApp

type MngApp struct {
	ID              int64   `json:"id" form:"id"`
	Business        string  `json:"business" form:"business"`
	AppID           string  `json:"appid" form:"appid"`
	Desc            string  `json:"desc" form:"desc"`
	DBName          string  `json:"db_name" form:"db_name"`
	ESName          string  `json:"es_name" form:"es_name"`
	TableName       string  `json:"table_name" form:"table_name"`
	TablePrefix     string  `json:"-"`
	TableFormat     string  `json:"-"`
	DatabusName     string  `json:"databus_name" form:"databus_name"`
	DatabusInfo     string  `json:"-"`
	DatabusIndexID  string  `json:"-"`
	IndexPrefix     string  `json:"index_prefix" form:"index_prefix"`
	IndexVersion    string  `json:"index_version" form:"index_version"`
	IndexFormat     string  `json:"index_format" form:"index_format"`
	IndexType       string  `json:"index_type" form:"index_type"`
	IndexID         string  `json:"index_id" form:"index_id"`
	DataIndexSuffix string  `json:"data_index_suffix" form:"data_index_suffix"`
	IndexMapping    string  `json:"index_mapping" form:"index_mapping"`
	DataFields      string  `json:"data_fields" form:"data_fields"`
	DataExtra       string  `json:"data_extra" form:"data_extra"`
	ReviewNum       int     `json:"review_num" form:"review_num"`
	ReviewTime      int     `json:"review_time" form:"review_time"`
	Sleep           float64 `json:"sleep" form:"sleep"`
	Size            int     `json:"size" form:"size"`
	SQLByID         string  `json:"sql_by_id" form:"sql_by_id"`
	SQLByMtime      string  `json:"sql_by_mtime" form:"sql_by_mtime"`
	SQLByIDMtime    string  `json:"sql_by_idmtime" form:"sql_by_idmtime"`
	QueryMaxIndexes int     `json:"query_max_indexes" form:"query_max_indexes"`
}

MngApp .

type MngAsset

type MngAsset struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	Type   int    `json:"type"`
	Config string `json:"config"`
	Desc   string `json:"desc"`
}

MngAsset .

type MngAssetDatabus

type MngAssetDatabus struct {
	DatabusInfo    string `json:"info"`
	DatabusIndexID string `json:"index_id"`
}

MngAssetDatabus .

type MngAssetTable

type MngAssetTable struct {
	TablePrefix string `json:"prefix"`
	TableFormat string `json:"format"`
}

MngAssetTable .

type MngBusiness

type MngBusiness struct {
	ID       int64             `json:"id"`
	Name     string            `json:"name"`
	Desc     string            `json:"desc"`
	Apps     []*MngBusinessApp `json:"apps"`
	AppsJSON string            `json:"-"`
}

MngBusiness .

type MngBusinessApp

type MngBusinessApp struct {
	AppID    string `json:"appid"`
	IncrWay  string `json:"incr_way"`
	IncrOpen bool   `json:"incr_open"`
}

MngBusinessApp .

type MngCount

type MngCount struct {
	Business string `json:"business" form:"business"`
	Type     string `json:"type" form:"type"`
	Name     string `json:"name"`
	Chart    string `json:"chart"`
	Param    string `json:"param"`
}

MngCount .

type MngCountRes

type MngCountRes struct {
	Time  string `json:"time"`
	Count string `json:"count"`
}

MngCountRes .

type MngPercentRes

type MngPercentRes struct {
	Name  string `json:"name"`
	Count string `json:"count"`
}

MngPercentRes .

type Page

type Page struct {
	Pn    int   `json:"num"`
	Ps    int   `json:"size"`
	Total int64 `json:"total"`
}

Page .

type Pager

type Pager struct {
	Pn int `form:"pn" validate:"min=1" default:"1"`
	Ps int `form:"ps" validate:"min=1" default:"10"`
}

Pager .

type ParamMngAsset

type ParamMngAsset struct {
	ID     int64  `form:"id"`
	Type   int    `form:"type"`
	Name   string `form:"name"`
	Config string `form:"config"`
	Desc   string `form:"desc"`
	Pager
}

ParamMngAsset .

type ParamMngBusiness

type ParamMngBusiness struct {
	ID    int64  `form:"id"`
	Name  string `form:"name"`
	Desc  string `form:"desc"`
	Apps  string `form:"apps"`
	IsJob bool   `form:"is_job"`
	Pager
}

ParamMngBusiness .

type ParamMngBusinessApp

type ParamMngBusinessApp struct {
	Business string `form:"business"`
	App      string `form:"app"`
	IsJob    bool   `form:"is_job"`
	IncrWay  string `form:"incr_way"`
	IncrOpen bool   `form:"incr_open"`
}

ParamMngBusinessApp .

type QueryBody

type QueryBody struct {
	Fields          []string            `json:"fields"` // default:"*" _source,default = *
	From            string              `json:"from"`   //索引名,多个用逗号隔开
	Where           *QueryBodyWhere     `json:"where"`
	Order           []map[string]string `json:"order"`
	OrderScoreFirst bool                `json:"order_score_first"`
	OrderRandomSeed string              `json:"order_random_seed"` // 随机排序种子
	Scroll          bool                `json:"scroll"`
	Highlight       bool                `json:"highlight"` //default:"false"
	Pn              int                 `json:"pn"`        //Range(1,5000) default:"1"
	Ps              int                 `json:"ps"`        //Range(1,1000) default:"10"
}

QueryBody .

type QueryBodyWhere

type QueryBodyWhere struct {
	EQ       map[string]interface{}     `json:"eq"`    //可能是数据或字符,[12,333,67] ["asd", "你好"]
	Or       map[string]interface{}     `json:"or"`    //暂时不支持minimum should
	In       map[string][]interface{}   `json:"in"`    //TODO改造为slice
	Range    map[string]string          `json:"range"` //[10,20)  (2018-05-10 00:00:00,2018-05-31 00:00:00]  (,30]
	Like     []QueryBodyWhereLike       `json:"like"`
	Enhanced []QueryBodyWhereEnhanced   `json:"enhanced"` //包含GourpBy Collapse
	Combo    []QueryBodyWhereCombo      `json:"combo"`    //混合与或
	Not      map[string]map[string]bool `json:"not"`      //对eq、in、range条件取反
}

QueryBodyWhere .

type QueryBodyWhereCombo

type QueryBodyWhereCombo struct {
	EQ       []map[string]interface{}   `json:"eq"`
	In       []map[string][]interface{} `json:"in"`
	Range    []map[string]string        `json:"range"`
	NotEQ    []map[string]interface{}   `json:"not_eq"`
	NotIn    []map[string][]interface{} `json:"not_in"`
	NotRange []map[string]string        `json:"not_range"`
	Min      struct {
		EQ       int `json:"eq"`
		In       int `json:"in"`
		Range    int `json:"range"`
		NotEQ    int `json:"not_eq"`
		NotIn    int `json:"not_in"`
		NotRange int `json:"not_range"`
		Min      int `json:"min"`
	} `json:"min"`
}

QueryBodyWhereCombo .

type QueryBodyWhereEnhanced

type QueryBodyWhereEnhanced struct {
	Mode  string              `json:"mode"`
	Field string              `json:"field"`
	Order []map[string]string `json:"order"`
	Size  int                 `json:"size"` //todo:sdk增加子集返回数

}

QueryBodyWhereEnhanced .

type QueryBodyWhereLike

type QueryBodyWhereLike struct {
	KWFields []string `json:"kw_fields"`
	KW       []string `json:"kw"`    //将kw的值使用空白间隔给query
	Or       bool     `json:"or"`    //default:"false"
	Level    string   `json:"level"` //默认default
}

QueryBodyWhereLike .

type QueryConfDetail

type QueryConfDetail struct {
	ESCluster     string
	IndexPrefix   string
	IndexType     string
	IndexID       string
	IndexMapping  string
	MaxIndicesNum int
	QueryMode     int //1:默认完全走查询体 2:基于查询体的定制 3:nested查询
	MaxPageSize   int //最大page size
}

QueryConfDetail .

type QueryDebugResult

type QueryDebugResult struct {
	ErrMsg    []string               `json:"err_msg"`
	QueryBody string                 `json:"query_body"`
	DSL       string                 `json:"dsl"`
	Mapping   map[string]interface{} `json:"mapping"`
	Profile   *elastic.SearchProfile `json:"profile"` //性能分析
}

QueryDebugResult query result.

func (*QueryDebugResult) AddErrMsg

func (qdr *QueryDebugResult) AddErrMsg(msg ...string)

AddErrMsg .

type QueryParams

type QueryParams struct {
	Business     string `form:"business" params:"business;Required" validate:"required"`
	QueryBodyStr string `form:"query" params:"query;Required" validate:"required"`
	DebugLevel   int    `form:"debug_level" params:"debug_level" default:"0"` // 2 默认全局debug,(包含dsl执行后的分析),1 dsl执行前的分析,防止504啥分析看不到。通过 /x/admin/search/query/debug (※包含es query体是否正确 + dsl体 + explain 返回信息) 方式,非签名请求
	QueryBody    *QueryBody
	AppIDConf    *QueryConfDetail
}

QueryParams .

type QueryResult

type QueryResult struct {
	Order  string            `json:"order"`
	Sort   string            `json:"sort"`
	Result json.RawMessage   `json:"result"`
	Debug  *QueryDebugResult `json:"debug"`
	Page   *Page             `json:"page"`
}

QueryResult query result.

type SearchResult

type SearchResult struct {
	Order  string            `json:"order"`
	Sort   string            `json:"sort"`
	Result []json.RawMessage `json:"result"`
	Debug  string            `json:"debug"`
	Page   *Page             `json:"page"`
}

SearchResult search result (deprecated).

type TableField

type TableField struct {
	Name    string `json:"name"`
	Type    string `json:"type"`
	Count   int    `json:"count"`
	Primary bool   `json:"primary"`
}

TableField .

type TaskQa

type TaskQa struct {
	Bsp           *BasicSearchParams
	Ids           []int64  `form:"ids,split" params:"ids"`
	TaskIds       []string `form:"task_ids,split" params:"task_ids"`
	Uids          []string `form:"uids,split" params:"uids"`
	ArcTagIds     []string `form:"arc_tagids,split" params:"arc_tagids"`
	AuditTagIds   []int64  `form:"audit_tagids,split" params:"audit_tagids"`
	UpGroups      []string `form:"up_groups,split" params:"up_groups"`
	ArcTitles     []string `form:"arc_titles,split" params:"arc_titles"`
	ArcTypeIds    []string `form:"arc_typeids,split" params:"arc_typeids"`
	States        []string `form:"states,split" params:"states"`
	AuditStatuses []string `form:"audit_statuses,split" params:"audit_statuses"`
	FansFrom      string   `form:"fans_from" params:"fans_from"`
	FansTo        string   `form:"fans_to" params:"fans_to"`
	CtimeFrom     string   `form:"ctime_from" params:"ctime_from"`
	CtimeTo       string   `form:"ctime_to" params:"ctime_to"`
	FtimeFrom     string   `form:"ftime_from" params:"ftime_from"`
	FtimeTo       string   `form:"ftime_to" params:"ftime_to"`
}

TaskQa .

type TaskQaFansParams

type TaskQaFansParams struct {
	ID   int64 `json:"id"`
	Fans int64 `json:"fans"`
}

TaskQaFansParams .

func (*TaskQaFansParams) IndexID

func (m *TaskQaFansParams) IndexID() string

IndexID .

func (*TaskQaFansParams) IndexName

func (m *TaskQaFansParams) IndexName() string

IndexName .

func (*TaskQaFansParams) IndexType

func (m *TaskQaFansParams) IndexType() string

IndexType .

type UDepTsData

type UDepTsData struct {
	Code int `json:"code"`
	Data map[string]string
}

UDepTsData .

type UNameParams

type UNameParams struct {
	Bsp   *BasicSearchParams
	MIds  []int64 `form:"mids,split" params:"mids"`
	Sex   int64   `form:"sex" params:"sex" default:"-1"`
	Ranks []int64 `form:"ranks,split" params:"ranks"`
}

UNameParams search params.

type UnamesData

type UnamesData struct {
	Code int `json:"code"`
	Data map[string]string
}

UnamesData .

type UpdateParams

type UpdateParams map[string]interface{}

UpdateParams update params (deprecated).

type UpsertBody

type UpsertBody struct {
	IndexName string
	IndexType string
	IndexID   string
	Doc       MapData
}

UpsertBody job的bulk优化参考这个模板 .

type UpsertParams

type UpsertParams struct {
	Business   string `form:"business" validate:"required"`
	DataStr    string `form:"data" validate:"required"`
	Insert     bool   `form:"insert" default:"false"`
	UpsertBody []UpsertBody
}

UpsertParams .

type UpsertResult

type UpsertResult struct {
}

UpsertResult upsert result.

type VideoParams

type VideoParams struct {
	Bsp        *BasicSearchParams
	VIDs       []int64  `form:"vids,split" params:"vids"`
	AIDs       []int64  `form:"aids,split" params:"aids"`
	CIDs       []int64  `form:"cids,split" params:"cids"`
	TIDs       []int64  `form:"tids,split" params:"tids"`
	FileNames  []string `form:"filename,split" params:"filename"`
	TagID      int64    `form:"tag_id" params:"tag_id"`
	Status     []int64  `form:"status,split" params:"status"`
	XCodeState []int64  `form:"xcode_state,split" params:"xcode_state"`
	UserType   int      `form:"user_type" params:"user_type"`
	// archive
	RelationStates []int64 `form:"relation_state,split" params:"relation_state"`
	ArcMids        []int64 `form:"arc_mids,split" params:"arc_mids"`
	DurationFrom   int     `form:"duration_from" params:"duration_from"`
	DurationTo     int     `form:"duration_to" params:"duration_to"`
	// other
	OrderType int `form:"order_type" params:"order_type"`
}

VideoParams search video

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL