Documentation ¶
Overview ¶
Package query implements an api for adding and executing Lucene queries associate with an account.
Index ¶
- Constants
- func GetQueryTemplateMapping() es.IndexTemplate
- type Api
- func (a *Api) ExecuteQuery(account string, query Query, c *gin.Context) (int, *es.Obj, *es.ErrorResponse, error)
- func (a *Api) ExecuteQueryHandlerF(system bool) gin.HandlerFunc
- func (a *Api) GetQuery(account string, id string) (int, *Result, error)
- func (a *Api) GetQueryHandler(c *gin.Context)
- func (a *Api) RunQueryHandler(c *gin.Context)
- func (a *Api) SearchQueries(account string, searchObj *es.Obj) (int, SearchResults, *es.ErrorResponse, error)
- func (a *Api) SearchQueryHandler(c *gin.Context)
- func (a *Api) UpsertQuery(account string, query *Query) (int, es.Result, *es.ErrorResponse, error)
- func (a *Api) UpsertQueryHandler(c *gin.Context)
- type Config
- type Query
- type Result
- type SearchResults
- type SearchResultsAck
Constants ¶
View Source
const IdxQuery = "queries"
Variables ¶
This section is empty.
Functions ¶
func GetQueryTemplateMapping ¶
func GetQueryTemplateMapping() es.IndexTemplate
GetModelsTemplateMapping
Types ¶
type Api ¶
type Api struct {
*Config
}
Api
func (*Api) ExecuteQuery ¶
func (a *Api) ExecuteQuery(account string, query Query, c *gin.Context) (int, *es.Obj, *es.ErrorResponse, error)
ExecuteQuery
func (*Api) ExecuteQueryHandlerF ¶ added in v0.3.0
func (a *Api) ExecuteQueryHandlerF(system bool) gin.HandlerFunc
ExecuteQueryHandler
func (*Api) SearchQueries ¶
func (a *Api) SearchQueries(account string, searchObj *es.Obj) (int, SearchResults, *es.ErrorResponse, error)
SearchQueries
func (*Api) SearchQueryHandler ¶
SearchQueryHandler
func (*Api) UpsertQuery ¶
UpsertQuery
func (*Api) UpsertQueryHandler ¶
UpsertQueryHandler
type Config ¶
type Config struct { Logger *zap.Logger HttpClient *micro.Client // used for communication with Elasticsearch // if nil, HttpClient will be used. Elastic *es.Client ElasticServer string // for storage and retrieval of system_ queries SystemIdxPrefix string }
Config
type Query ¶
type Query struct { // a lowercase under score delimited uniq id MachineName string `json:"machine_name" mapstructure:"machine_name"` // short human readable display name DisplayName string `json:"display_name" mapstructure:"display_name"` // a single sentence description BriefDescription string `json:"description_brief" mapstructure:"description_brief"` // full documentation in markdown Description string `json:"description" mapstructure:"description"` // named parsers Parsers []string `json:"parsers" mapstructure:"parsers"` // belongs to a class of queries QueryClass string `json:"query_class" mapstructure:"query_class"` // used for grouping queries Group string `json:"group" mapstructure:"group"` // used for grouping queries Model string `json:"model" mapstructure:"model"` // pattern default "-*" eg. "-someset", "-ts-2019*" IdxPattern string `json:"idx_pattern" mapstructure:"idx_pattern"` // query object Query *es.Obj `json:"query,omitempty" mapstructure:"query"` // used to describe input parameters Parameters []tm.Model `json:"parameters,omitempty" mapstructure:"parameters"` // query json QueryJson string `json:"query_json,omitempty" mapstructure:"query_json"` // if a query template is present it will take the place of // the query and query_json fields QueryTemplate string `json:"query_template,omitempty" mapstructure:"query_template"` // describes the query output ResultFields []tm.Model `json:"fields" mapstructure:"fields"` }
Query
type Result ¶
type Result struct { es.Result Source Query `json:"_source"` }
Result returned from Elastic
type SearchResults ¶
type SearchResults struct { es.SearchResults Hits struct { Total int `json:"total"` MaxScore float64 `json:"max_score"` Hits []Result `json:"hits"` } `json:"hits"` }
SearchResults
type SearchResultsAck ¶
type SearchResultsAck struct { ack.Ack Payload SearchResults `json:"payload"` }
SearchResultsAck
Click to show internal directories.
Click to hide internal directories.