modeler

package
v4.2.7 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFieldPath

func BuildFieldPath(name string, fields []Field) string

BuildFieldPath returns the full fields tree path to a field

func FindFieldLeaf

func FindFieldLeaf(search string, parent string, fields []Field) bool

FindFieldLeaf returns if a field name exists in a fields tree

Types

type ElasticsearchAdvancedSettings

type ElasticsearchAdvancedSettings map[string]interface{}

ElasticsearchAdvancedSettings is a wrapper for advanced elasticsearch template settings like "number_of_shards", "number_of_replica", etc.

type ElasticsearchOptions

type ElasticsearchOptions struct {
	// Rollmode can only be "rollover" atm
	Rollmode                  string                        `json:"rollmode"`
	Rollcron                  string                        `json:"rollcron"`
	EnablePurge               bool                          `json:"enablePurge"`
	PurgeMaxConcurrentIndices int                           `json:"purgeMaxConcurrentIndices"`
	PatchAliasMaxIndices      int                           `json:"patchAliasMaxIndices"`
	AdvancedSettings          ElasticsearchAdvancedSettings `json:"advancedSettings,omitempty"`
}

ElasticsearchOptions regroups every elasticsearch specific options

func (ElasticsearchOptions) IsValid

func (eso ElasticsearchOptions) IsValid() (bool, error)

IsValid checks if a model elasticsearch options is valid and has no missing mandatory fields

type Field

type Field interface {
	Source() (string, map[string]interface{})
	IsValid() (bool, error)
}

Field is an interface for recursive mapping modeling (Leaf fields and object fields)

type FieldLeaf

type FieldLeaf struct {
	Name     string    `json:"name"`
	Ftype    FieldType `json:"type"`
	Semantic bool      `json:"semantic"`
	Synonyms []string  `json:"synonyms"`
}

FieldLeaf implements Field interface and represents a terminal node (or primitive type) in the modeler mapping

func (*FieldLeaf) IsValid

func (field *FieldLeaf) IsValid() (bool, error)

IsValid checks if a model field leaf is valid and has no missing mandatory fields

func (*FieldLeaf) Source

func (field *FieldLeaf) Source() (string, map[string]interface{})

Source (FieldLeaf) returns a elasticsearch field with a name and a slice of attributes It mainly process primitives elasticsearch data type

type FieldObject

type FieldObject struct {
	Name                 string    `json:"name"`
	Ftype                FieldType `json:"type"`
	KeepObjectSeparation bool      `json:"keepObjectSeparation"`
	Fields               []Field   `json:"fields"`
}

FieldObject implements Field interface and represents a non-terminal node (or object) in the modeler mapping

func (*FieldObject) IsValid

func (field *FieldObject) IsValid() (bool, error)

IsValid checks if a model definition is valid and has no missing mandatory fields

func (*FieldObject) Source

func (field *FieldObject) Source() (string, map[string]interface{})

Source (FieldObject) returns a elasticsearch field with a name and a slice of attributes It mainly manages "object" and "nested" elasticsearch data type

func (*FieldObject) UnmarshalJSON

func (field *FieldObject) UnmarshalJSON(b []byte) error

UnmarshalJSON (FieldObject) unmarshall a JSON byte slice in FieldObject struct

type FieldType

type FieldType int

FieldType is an enumeration of all allowed types in the modeler mapping

const (
	// String is elasticsearch keyword datatype
	String FieldType = iota + 1
	// Int is elasticsearch integer datatype
	Int
	// Float is elasticsearch float datatype
	Float
	// DateTime is elasticsearch date datatype with specific format {"type": "date", "format": "date_hour_minute_second_millis"}
	DateTime
	// Boolean is elasticsearch boolean datatype
	Boolean
	// Object is elasticsearch object or nested datatype (based on some other attributes)
	Object
)

func (FieldType) MarshalJSON

func (s FieldType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (FieldType) String

func (s FieldType) String() string

String returns the string version of FieldType

func (*FieldType) UnmarshalJSON

func (s *FieldType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type Model

type Model struct {
	ID                   int64                `json:"id"`
	Name                 string               `json:"name"`
	Synonyms             []string             `json:"synonyms"`
	Fields               []Field              `json:"fields"`
	Source               string               `json:"source,omitempty"`
	ElasticsearchOptions ElasticsearchOptions `json:"elasticsearchOptions"`
}

Model represents a business entity model

func (*Model) IsValid

func (model *Model) IsValid() (bool, error)

IsValid checks if a model definition is valid and has no missing mandatory fields

func (*Model) ToElasticsearchMappingProperties

func (model *Model) ToElasticsearchMappingProperties() map[string]interface{}

ToElasticsearchMappingProperties converts a modeler mapping to an elasticsearch mapping

func (*Model) UnmarshalJSON

func (model *Model) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a quoted json string to a Model instance

Jump to

Keyboard shortcuts

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