0
0
Fork 0

export the Validate method on mapping objects

This commit is contained in:
Marty Schoch 2016-03-28 17:14:41 -04:00
parent 639fb1ab89
commit 2b82387eae
3 changed files with 7 additions and 7 deletions

View File

@ -94,7 +94,7 @@ func newMemIndex(indexType string, mapping *IndexMapping) (*indexImpl, error) {
func newIndexUsing(path string, mapping *IndexMapping, indexType string, kvstore string, kvconfig map[string]interface{}) (*indexImpl, error) {
// first validate the mapping
err := mapping.validate()
err := mapping.Validate()
if err != nil {
return nil, err
}
@ -234,7 +234,7 @@ func openIndexUsing(path string, runtimeConfig map[string]interface{}) (rv *inde
rv.open = true
// validate the mapping
err = im.validate()
err = im.Validate()
if err != nil {
// note even if the mapping is invalid
// we still return an open usable index

View File

@ -39,7 +39,7 @@ type DocumentMapping struct {
DefaultAnalyzer string `json:"default_analyzer"`
}
func (dm *DocumentMapping) validate(cache *registry.Cache) error {
func (dm *DocumentMapping) Validate(cache *registry.Cache) error {
var err error
if dm.DefaultAnalyzer != "" {
_, err := cache.AnalyzerNamed(dm.DefaultAnalyzer)
@ -48,7 +48,7 @@ func (dm *DocumentMapping) validate(cache *registry.Cache) error {
}
}
for _, property := range dm.Properties {
err = property.validate(cache)
err = property.Validate(cache)
if err != nil {
return err
}

View File

@ -244,7 +244,7 @@ func NewIndexMapping() *IndexMapping {
// Validate will walk the entire structure ensuring the following
// explicitly named and default analyzers can be built
func (im *IndexMapping) validate() error {
func (im *IndexMapping) Validate() error {
_, err := im.cache.AnalyzerNamed(im.DefaultAnalyzer)
if err != nil {
return err
@ -253,12 +253,12 @@ func (im *IndexMapping) validate() error {
if err != nil {
return err
}
err = im.DefaultMapping.validate(im.cache)
err = im.DefaultMapping.Validate(im.cache)
if err != nil {
return err
}
for _, docMapping := range im.TypeMapping {
err = docMapping.validate(im.cache)
err = docMapping.Validate(im.cache)
if err != nil {
return err
}