func newBleveIndex(path string, readOnly bool) (*bleveService, error) {
	config := map[string]interface{}{
		"read_only": readOnly,
	}
	index, err := bleve.OpenUsing(path, config)
	if err == nil {
		return &bleveService{index: index}, err
	}
	if err != bleve.ErrorIndexPathDoesNotExist {
		return nil, err
	}
	if readOnly {
		return nil, fmt.Errorf("cannot open index in read-only mode: index doesn't exist at %s", path)
	}
	indexMapping := bleve.NewIndexMapping()
	documentMapping := bleve.NewDocumentMapping()  
	indexMapping.AddDocumentMapping("document", documentMapping)
	indexMapping.DefaultType = "document"
	idMapping := bleve.NewTextFieldMapping()
	idMapping.IncludeInAll = false
	idMapping.IncludeTermVectors = false
	idMapping.Store = true
	idMapping.Analyzer = keyword.Name
	termMapping := bleve.NewTextFieldMapping()
	termMapping.Analyzer = "en"
	termMapping.Store = false
	documentMapping.AddFieldMappingsAt("Term", termMapping)
	keywordMapping := bleve.NewTextFieldMapping()
	keywordMapping.Analyzer = keyword.Name
	keywordMapping.Store = false
	keywordMapping.IncludeInAll = false
	keywordMapping.IncludeTermVectors = false
	boolMapping := bleve.NewBooleanFieldMapping()
	boolMapping.IncludeInAll = false
	boolMapping.Store = false
	documentMapping.AddFieldMappingsAt("RecursiveParents", keywordMapping)
	documentMapping.AddFieldMappingsAt("DirectParents", keywordMapping)
	documentMapping.AddFieldMappingsAt("ConceptRefsets", keywordMapping)
	documentMapping.AddFieldMappingsAt("DescriptionRefsets", keywordMapping)
	documentMapping.AddFieldMappingsAt("DirectParents", keywordMapping)
	documentMapping.AddFieldMappingsAt("ConceptActive", boolMapping)
	documentMapping.AddFieldMappingsAt("DescriptionActive", boolMapping)
	index, err = bleve.NewUsing(path, indexMapping, scorch.Name, scorch.Name, nil)
	return &bleveService{index: index}, err
}
NewBleveIndex creates or opens a bleve index at the location specified.
package terminology
import (
	"fmt"
	"strconv"
	"strings"
	"github.com/blevesearch/bleve"
	"github.com/blevesearch/bleve/analysis/analyzer/keyword"
	"github.com/blevesearch/bleve/index/scorch"
	"github.com/wardle/go-terminology/snomed"
)
type bleveService struct {
	index bleve.Index
}
type document struct {
	ID   string  
	Term string  
	RecursiveParents   []string
	DirectParents      []string
	ConceptRefsets     []string
	DescriptionRefsets []string
	ConceptActive      bool
	DescriptionActive  bool
}