elasticmapper

package
v0.0.0-...-563cfe6 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MPL-2.0 Imports: 5 Imported by: 0

README

Elastic Mapper - Generate ElasticSearch Type Mapping

I'm using Reflection to try and auto-generate ElasticSearch mapping JSON.

I don't currently check or respect the json tags to see if the name rendered is the same as what would be if the object is serialized so don't use this in production! It works for a very specific use-case with lots of autogenerated code I'm dealing with.

I've also hard-coded a check for time.Time and I'm sure there's a better way of doing this.

Hopefully this snippet outgrows this repository and becomes a tool by itself.

github.com/Jeffail/gabs made it really easy to generate a complex JSON tree.

Text vs Keyword fields

Use elasticmapper:"text" to specify that a string field is text. Otherwise I assume it is a keyword. I should make this bit configurable as a flag to decide what the default is.

Nested Objects

Logically, you want an array of structs to be a nested object. Nested structs are just simple objects that ElasticSearch can flatten.

ElasticSearch Documentation References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetElasticMapping

func GetElasticMapping(input interface{}, typeName string) (mapping string, err error)

GetElasticMapping returns an ElasticSearch mapping from a struct Arguments: input, which could be any struct and typeName, which is the name of the type you wish to set in ElasticSearch

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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