func (dbc *Client) FindIndices(indexPattern string) ([]string, error) {
	var records []IndexRecord
	var results []string
	indexPattern = strings.Replace(indexPattern, "?", "_", -1)
	indexPattern = strings.Replace(indexPattern, "*", "%", -1)
	query := dbc.connection.Model(&IndexRecord{}).Where("name LIKE ?", indexPattern)
	err := query.Select(&records)
	if err != nil {
		return nil, err
	}
	for _, v := range records {
		results = append(results, v.Name)
	}
	return results, nil
}
FindIndices searches for indicies using name pattern in ElasticSearch wildcard format
package db
import (
	"fmt"
	"github.com/asp437/pg_elastic/utils"
	"github.com/go-pg/pg"
	"github.com/go-pg/pg/orm"
	"strings"
)
type Client struct {
	connection *pg.DB
}
type Query = orm.Query
type IndexRecord struct {
	Name    string
	Options string
}
type TypeRecord struct {
	Name      string
	IndexName string
	Options   string
}
type ElasticSearchDocument struct {
	ID       string
	Document interface{}
	Version  int
}
func CreateClient(config utils.PostgresConnectionConfig) (result *Client) {
	result = new(Client)
	result.connection = pg.Connect(&pg.Options{
		User:     config.User,
		Addr:     config.ServerAddress,
		Password: config.Password,
		Database: config.DBName,
	})
	return result
}
func (dbc *Client) InitializeSchema() error {
	for _, model := range []interface{}{&IndexRecord{}, &TypeRecord{}} {
		err := dbc.connection.CreateTable(model, &orm.CreateTableOptions{IfNotExists: true})
		if err != nil {
			return err
		}
	}
	return nil
}
func (dbc *Client) NewQuery(indexName, typeName string) *Query {
	tableName := fmt.Sprintf("%s_%s", indexName, typeName)
	return dbc.connection.Model().Table(tableName)
}
func (dbc *Client) ProcessSearchQuery(indexName, typeName string, query *Query) ([]ElasticSearchDocument, error) {
	var documentObject []ElasticSearchDocument
	c, err := query.Count()
	if err != nil {
		return nil, utils.NewDBQueryError(err.Error())
	}
	if c == 0 {
		return nil, nil
	}
	err = query.Select(&documentObject)
	if err != nil {
		return nil, utils.NewDBQueryError(err.Error())
	}
	return documentObject, nil
}
func (dbc *Client) CreateIndex(indexName, options string) (*IndexRecord, error) {
	var indexRecord IndexRecord
	indexSelectQuery := dbc.connection.Model(&IndexRecord{}).Where("Name = ?", indexName)
	count, err := indexSelectQuery.Count()
	if err != nil {
		return nil, utils.NewDBQueryError(err.Error())
	}
	if count == 0 {
		indexRecord = IndexRecord{Name: indexName, Options: options}
		err = dbc.connection.Insert(&indexRecord)
		if err != nil {
			return nil, utils.NewDBQueryError(err.Error())
		}
	} else {
		return nil, utils.NewIllegalQueryError("Index already exists")
	}
	indexSelectQuery.Select(&indexRecord)
	return &indexRecord, nil
}
func (dbc *Client) GetIndex(indexName string) (*IndexRecord, error) {
	var indexRecord IndexRecord
	indexSelectQuery := dbc.connection.Model(&IndexRecord{}).Where("Name = ?", indexName)
	count, err := indexSelectQuery.Count()
	if err != nil {
		return nil, utils.NewDBQueryError(err.Error())
	}
	if count == 0 {
		return nil, nil
	}
	indexSelectQuery.Select(&indexRecord)
	if err != nil {
		return nil, utils.NewDBQueryError(err.Error())
	}
	return &indexRecord, nil
}