mapping

package
v0.0.0-...-7b3ddb2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexField      = "_index"
	UidField        = "_uid"
	TypeField       = "_type"
	IdField         = "_id"
	SourceField     = "_source"
	SizeField       = "_size"
	AllField        = "_all"
	FieldNamesField = "_field_names"
	IgnoredField    = "_ignored"
	RoutingField    = "_routing"
	MetaField       = "_meta"
	VersionField    = "_version"
	SlotField       = "_slot"
)

Variables

Functions

func Equals

func Equals(f1, f2 FieldMappingI) bool

func MergeSchema

func MergeSchema(old, new []byte) ([]byte, error)

merge two schema to a new one

func SchemaMap

func SchemaMap(schema []byte) (map[string]FieldMappingI, error)

make schema to map[path]FieldMapping level is 1

Types

type BaseFieldMapping

type BaseFieldMapping struct {
	Type   pspb.FieldType   `json:"type"`
	Name   string           `json:"_"`
	Boost  float64          `json:"boost,omitempty"`
	Option pspb.FieldOption `json:"option,omitempty"`
	Array  bool             `json:"array,omitempty"`
}

func NewBaseFieldMapping

func NewBaseFieldMapping(name string, fieldType pspb.FieldType, boost float64, option pspb.FieldOption) *BaseFieldMapping

func (*BaseFieldMapping) Base

func (*BaseFieldMapping) FieldName

func (f *BaseFieldMapping) FieldName() string

func (*BaseFieldMapping) FieldType

func (f *BaseFieldMapping) FieldType() pspb.FieldType

func (*BaseFieldMapping) IsArray

func (f *BaseFieldMapping) IsArray() bool

func (*BaseFieldMapping) Options

func (f *BaseFieldMapping) Options() pspb.FieldOption

type BooleanFieldMapping

type BooleanFieldMapping struct {
	*BaseFieldMapping
	NullValue string `json:"null_value,omitempty"`
}

func NewBooleanFieldMapping

func NewBooleanFieldMapping(name string) *BooleanFieldMapping

type DateFieldMapping

type DateFieldMapping struct {
	*BaseFieldMapping
	Format          string `json:"format,omitempty"`
	Locale          string `json:"locale,omitempty"`
	NullValue       string `json:"null_value,omitempty"`
	IgnoreMalformed bool   `json:"ignore_malformed"`
}

func NewDateFieldMapping

func NewDateFieldMapping(name string) *DateFieldMapping

type DocumentMapping

type DocumentMapping struct {
	Properties map[string]*DocumentMapping `json:"properties,omitempty"`
	Field      *FieldMapping               `json:"field,omitempty"`
}

func NewDocumentMapping

func NewDocumentMapping() *DocumentMapping

func ParseSchema

func ParseSchema(schema []byte) (*DocumentMapping, error)

func (*DocumentMapping) UnmarshalJSON

func (dm *DocumentMapping) UnmarshalJSON(data []byte) error

type FieldMapping

type FieldMapping struct {
	Name string
	FieldMappingI
}

func NewFieldMapping

func NewFieldMapping(name string, i FieldMappingI) *FieldMapping

func (*FieldMapping) UnmarshalJSON

func (f *FieldMapping) UnmarshalJSON(data []byte) error

type FieldMappingI

type FieldMappingI interface {
	FieldName() string
	FieldType() pspb.FieldType
	Options() pspb.FieldOption
	Base() *BaseFieldMapping
	IsArray() bool
}

type GeoPointFieldMapping

type GeoPointFieldMapping struct {
	*BaseFieldMapping
	IgnoreZValue bool   `json:"ignore_z_value,omitempty"`
	NullValue    string `json:"null_value,omitempty"`
}

func NewGeoPointFieldMapping

func NewGeoPointFieldMapping(name string) *GeoPointFieldMapping

type IndexMapping

type IndexMapping struct {
	DocumentMapping *DocumentMapping `json:"doc_mapping"`
	//it is not config in index
	DefaultDateTimeParserName string `json:"-"`
	// contains filtered or unexported fields
}

An IndexMapping controls how objects are placed into an index. First the type of the object is determined. Once the type is know, the appropriate DocumentMapping is selected by the type. If no mapping was determined for that type, a DefaultMapping will be used.

func NewIndexMapping

func NewIndexMapping() *IndexMapping

NewIndexMapping creates a new IndexMapping that will use all the default indexing rules

func Space2Mapping

func Space2Mapping(space *entity.Space) (indexMapping *IndexMapping, err error)

func (*IndexMapping) GetDocument

func (im *IndexMapping) GetDocument(path string) *DocumentMapping

you can use it like dm.DocumentMappingForField("person.name")

func (*IndexMapping) GetField

func (im *IndexMapping) GetField(path string) *FieldMapping

you can use it like dm.DocumentMappingForField("person.name")

func (*IndexMapping) GetFieldsType

func (im *IndexMapping) GetFieldsType() map[string]pspb.FieldType

func (*IndexMapping) InitFieldCache

func (im *IndexMapping) InitFieldCache()

func (*IndexMapping) MapDocument

func (im *IndexMapping) MapDocument(source []byte) ([]*pspb.Field, map[string]pspb.FieldType, error)

func (*IndexMapping) RangeField

func (im *IndexMapping) RangeField(f func(key string, value *DocumentMapping) error) error

type NumericFieldMapping

type NumericFieldMapping struct {
	*BaseFieldMapping
	NullValue       string `json:"null_value,omitempty"`
	Coerce          bool   `json:"coerce"`
	IgnoreMalformed bool   `json:"ignore_malformed"`
}

func NewFloatFieldMapping

func NewFloatFieldMapping(name string) *NumericFieldMapping

func NewIntegerFieldMapping

func NewIntegerFieldMapping(name string) *NumericFieldMapping

type StringFieldMapping

type StringFieldMapping struct {
	*BaseFieldMapping
	NullValue string `json:"null_value,omitempty"`
}

func NewStringFieldMapping

func NewStringFieldMapping(name string) *StringFieldMapping

type VectortFieldMapping

type VectortFieldMapping struct {
	*BaseFieldMapping
	Dimension     int     `json:"dimension"`
	ModelId       string  `json:"model_id"`
	Format        *string `json:"format,omitempty"`         //"normalization", "normal"
	RetrievalType string  `json:"retrieval_type,omitempty"` // "IVFPQ", "PACINS", ...
	StoreType     string  `json:"store_type,omitempty"`     // "Mmap", "RocksDB"
	StoreParam    []byte  `json:"store_param,omitempty"`
}

func NewVectorFieldMapping

func NewVectorFieldMapping(name string) *VectortFieldMapping

Jump to

Keyboard shortcuts

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