//====================================================
//meta helpers
14094
func grepper(restr string) func(string) string {
	re := regexp.MustCompile(restr)
	return func(s string) string {
		matches := re.FindAllStringSubmatch(s, 1)
		if len(matches) != 1 {
			log.Fatalf("'%s' should match '%s' exactly once", restr, s)
		}
		groups := matches[0]
		if len(groups) != 2 {
			log.Fatalf("'%s' should have exactly one group (found %d)", restr, len(groups))
		}
		return groups[1]
	}
}
440359
func (a *SignificantTextAggregation) Meta(metaData map[string]interface{}) *SignificantTextAggregation {
	a.meta = metaData
	return a
}
1279628
func (a *SignificantTermsAggregation) Meta(metaData map[string]interface{}) *SignificantTermsAggregation {
	a.meta = metaData
	return a
}
731601
func (a *MatrixStatsAggregation) Meta(metaData map[string]interface{}) *MatrixStatsAggregation {
	a.meta = metaData
	return a
}
1272798
func (a *FiltersAggregation) Meta(metaData map[string]interface{}) *FiltersAggregation {
	a.meta = metaData
	return a
}
1100960
func Metadata(md map[string]string) Option {
	return func(o *Options) {
		o.Metadata = md
	}
}
1013104
func (a *MaxAggregation) Meta(metaData map[string]interface{}) *MaxAggregation {
	a.meta = metaData
	return a
}
1216517
func (meta MetaData) Update(other MetaData) {
	for name, tab := range other {

		if meta[name] == nil {
			meta[name] = make(map[string]interface{})
		}

		for key, value := range tab {
			meta[name][key] = value
		}
	}
}
1134902
func ValidateMetadata(meta map[string]string, allowConsulPrefix bool) error {
	if len(meta) > metaMaxKeyPairs {
		return fmt.Errorf("Node metadata cannot contain more than %d key/value pairs", metaMaxKeyPairs)
	}

	for key, value := range meta {
		if err := validateMetaPair(key, value, allowConsulPrefix); err != nil {
			return fmt.Errorf("Couldn't load metadata pair ('%s', '%s'): %s", key, value, err)
		}
	}

	return nil
}
1131948
func (a *MovAvgAggregation) Meta(metaData map[string]interface{}) *MovAvgAggregation {
	a.meta = metaData
	return a
}
808037
func (a *ReverseNestedAggregation) Meta(metaData map[string]interface{}) *ReverseNestedAggregation {
	a.meta = metaData
	return a
}
777143
func (a *StatsAggregation) Meta(metaData map[string]interface{}) *StatsAggregation {
	a.meta = metaData
	return a
}
487859
func (a *BucketSelectorAggregation) Meta(metaData map[string]interface{}) *BucketSelectorAggregation {
	a.meta = metaData
	return a
}
171320
func Meta() *plugin.PluginMeta {
	return plugin.NewPluginMeta(
		Name,
		Version,
		Type,
		[]string{plugin.SnapGOBContentType},
		[]string{plugin.SnapGOBContentType},
		plugin.CacheTTL(100*time.Millisecond),
		plugin.RoutingStrategy(plugin.StickyRouting),
	)
}
396269
func (b *RouteBuilder) Metadata(key string, value interface{}) *RouteBuilder {
	if b.metadata == nil {
		b.metadata = map[string]interface{}{}
	}
	b.metadata[key] = value
	return b
}
910385
func (a *GeoBoundsAggregation) Meta(metaData map[string]interface{}) *GeoBoundsAggregation {
	a.meta = metaData
	return a
}
1316811
func cleanMetadataKeys(metadata map[string]string, keyNames ...string) map[string]string {
	var newMeta = make(map[string]string)
	for k, v := range metadata {
		if contains(keyNames, k) {
			continue
		}
		newMeta[k] = v
	}
	return newMeta
}