elasticsearchCRUD

package
v0.0.0-...-646b7d3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package elasticsearchCRUD provides APIs for storing and retrieving objects from Elasticsearch and searching among those objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayOfRefsAsJSON

func ArrayOfRefsAsJSON(refs []*firestore.DocumentRef) string

ArrayOfRefsAsJSON converts and array of DocumentRefs into something which can be indexed in elasticsearch

func Create

func Create(client *elasticsearch.Client, i common.Queryable, collectionName string) error

Create creates a new Queryable document from the given collectionName. A query is performed to ensure duplicate FirestoreIDs are not being entered.

func Delete

func Delete(client *elasticsearch.Client, firestoreID string, collectionName string) error

Delete will deleteByQuery any provided FirestoreID via a query. If no document is found an error is NOT thrown.

func GetClient

func GetClient() (*elasticsearch.Client, error)

GetClient gets a client. User Role documentation (since apparently there's nowhere else to put this?) apm_system Role to enable the Health Check test to run. monitoring_user because we may wish to monitor our cluster at runtime. Web_Server gives it access to the indices for this app and a test index, /test.

func PrintResponseError

func PrintResponseError(res *esapi.Response)

PrintResponseError prints out some error information from a es response Call this if res.IsError()

func Read

func Read(client *elasticsearch.Client, firestoreID string, collectionName string) (commonObject interface{}, docID string, err error)

Read a document from the given collectionName. A query is performed to do this.

func Update

func Update(client *elasticsearch.Client, i common.Queryable, collectionName string) error

Update will deleteByQuery all documents at a specified FirestoreID via a query. It does NOT use the standard Merge method, so it's very possible the information in Elasticsearch will not be the same as the information in other databases if this function is used.

Types

type ESIter

type ESIter struct {
	// contains filtered or unexported fields
}

ESIter implements the common.Iter interface.

func (*ESIter) Length

func (E *ESIter) Length() int

Length of the results.

func (*ESIter) Next

func (E *ESIter) Next() (common.Queryable, error)

Next returns the next search result or common.IterDone.

func (*ESIter) Stop

func (E *ESIter) Stop()

Stop stops the iterator, freeing its resources.

type Query

type Query struct {
	// contains filtered or unexported fields
}

func (*Query) AddArrayContains

func (q *Query) AddArrayContains(k string, v string) error

AddArrayContains is unimplemented.

func (*Query) AddEquals

func (q *Query) AddEquals(k string, v string)

AddEquals searches for any field name 'k' which includes all of the input values.

func (*Query) Init

func (q *Query) Init(industryID string, domainID string, collectionID string, collection string)

Init this query. This should be called first. collectionID parameter is optional & SHOULD be used for collection Data.

func (*Query) QueryRead

func (q *Query) QueryRead() (common.Iter, error)

QueryRead performs the created query and returns results. This is a Term query. Because Firestore already gives us (better) access to regular Querying, the QueryRead() function here tries fuzzy matching.

While iterating through the results I highly recommend casting each result to the appropriate struct, like *common.Data.

func (*Query) Validate

func (q *Query) Validate() error

Validate returns an error if the query is dangerous.

Jump to

Keyboard shortcuts

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