Documentation ¶
Index ¶
- Constants
- Variables
- type Cas
- type CompoundQueries
- type Configuration
- type FacetDef
- type Handler
- func (h *Handler) CompoundSearch(ctx context.Context, index string, q *CompoundQueries) ([]gocb.SearchResultHit, error)
- func (h *Handler) CompoundSearchWithFacets(ctx context.Context, index string, q *CompoundQueries, facets []FacetDef) ([]gocb.SearchResultHit, map[string]gocb.SearchResultFacet, error)
- func (h *Handler) CountIndex(ctx context.Context, indexName string) (*IndexCount, error)
- func (h *Handler) CreateFullTextSearchIndex(ctx context.Context, def *IndexDefinition) error
- func (h *Handler) DeleteFullTextSearchIndex(ctx context.Context, indexName string) error
- func (h *Handler) EInsert(ctx context.Context, typ, id string, q interface{}, ttl uint32) (Cas, string, error)
- func (h *Handler) Get(ctx context.Context, typ, id string, ptr interface{}) error
- func (h *Handler) GetAndTouch(ctx context.Context, typ, id string, ptr interface{}, ttl uint32) error
- func (h *Handler) GetBulk(ctx context.Context, hits []gocb.SearchResultHit, container interface{}) error
- func (h *Handler) GetManager(ctx context.Context) *gocb.BucketManager
- func (h *Handler) Index(ctx context.Context, v interface{}) error
- func (h *Handler) IndexStat(ctx context.Context, indexName string) (*IndexStat, error)
- func (h *Handler) Insert(ctx context.Context, typ, id string, q interface{}, ttl uint32) (Cas, string, error)
- func (h *Handler) InspectFullTextSearchIndex(ctx context.Context, indexName string) (bool, *IndexDefinition, error)
- func (h *Handler) Ping(ctx context.Context, services []gocb.ServiceType) (*gocb.PingReport, error)
- func (h *Handler) RangeSearch(ctx context.Context, index string, q *RangeQuery) ([]gocb.SearchResultHit, error)
- func (h *Handler) RangeSearchWithFacets(ctx context.Context, index string, q *RangeQuery, facets []FacetDef) ([]gocb.SearchResultHit, map[string]gocb.SearchResultFacet, error)
- func (h *Handler) Remove(ctx context.Context, typ, id string, ptr interface{}) error
- func (h *Handler) SetDocumentType(ctx context.Context, name, prefix string) error
- func (h *Handler) SimpleSearch(ctx context.Context, index string, q *SearchQuery) ([]gocb.SearchResultHit, error)
- func (h *Handler) SimpleSearchWithFacets(ctx context.Context, index string, q *SearchQuery, facets []FacetDef) ([]gocb.SearchResultHit, map[string]gocb.SearchResultFacet, error)
- func (h *Handler) Touch(ctx context.Context, typ, id string, ptr interface{}, ttl uint32) error
- func (h *Handler) Upsert(ctx context.Context, typ, id string, q interface{}, ttl uint32) (Cas, string, error)
- func (h *Handler) ValidateState() (bool, error)
- type IndexCount
- type IndexDefaultMapping
- type IndexDefinition
- type IndexDefs
- type IndexDocConfig
- type IndexField
- type IndexMapping
- type IndexMeta
- type IndexParams
- type IndexPlanParams
- type IndexProperties
- type IndexStat
- type IndexStore
- type IndexType
- type NullTimeout
- type Opts
- type RangeQuery
- type SearchQuery
Constants ¶
const ( FacetDate = iota FacetNumeric FacetTerm )
Available facet types
Variables ¶
var ( // ErrDocumentTypeAlreadyExists document type already exist ErrDocumentTypeAlreadyExists = errors.New("document type already exists") // ErrDocumentTypeDoesntExists document type doesn't exist ErrDocumentTypeDoesntExists = errors.New("document type doesn't exist") // ErrEmptyField field must be filled ErrEmptyField = errors.New("field must be filled") // ErrEmptyIndex index must be filled ErrEmptyIndex = errors.New("index must be filled") // ErrEmptyType source type must be filled ErrEmptyType = errors.New("source type must set") // ErrEmptySource source name must be filled ErrEmptySource = errors.New("source name must set") // ErrEmptyRefTag referenced tag must be filled ErrEmptyRefTag = errors.New("referenced tag must set") // ErrConjunctionAndDisjunctionIsNil conjunction and disjunction are nil ErrConjunctionAndDisjunctionIsNil = errors.New("conjunction and disjunction are nil") // ErrEndAsTimeZero end as Time is zero instant ErrEndAsTimeZero = errors.New("endAsTime is zero instant") // ErrFirstParameterNotStruct first parameter is not a struct ErrFirstParameterNotStruct = errors.New("first parameter is not a struct") // ErrInputStructPointer input struct must be a pointer ErrInputStructPointer = errors.New("input struct must be pointer") // ErrInvalidBulkContainer bulk container type definition error ErrInvalidBulkContainer = errors.New("container must be *[]T, with length of ids array") // ErrInvalidGetDocumentTypesParam represents value for get document types should be pointer ErrInvalidGetDocumentTypesParam = errors.New("internal error: value should be pointer for getDocumentTypes") )
Functions ¶
This section is empty.
Types ¶
type CompoundQueries ¶
type CompoundQueries struct { Conjunction []SearchQuery `json:"conjuncts,omitempty"` Disjunction []SearchQuery `json:"disjuncts,omitempty"` Limit int `json:"-"` Offset int `json:"-"` }
CompoundQueries is a representation of the available search option for a CompoundSearch
type Configuration ¶
type Configuration struct { Username string `json:"username"` Password string `json:"password"` BucketName string `json:"bucket_name"` BucketPassword string `json:"bucket_password"` ConnectionString string `json:"connection_string"` Separator string `json:"separator"` Opts Opts `json:"bucket_opts"` }
Configuration the main library configuration
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is the main handler
func New ¶
func New(c *Configuration) (*Handler, error)
New creates a new handler from the configuration that handles the operations
func (*Handler) CompoundSearch ¶
func (h *Handler) CompoundSearch(ctx context.Context, index string, q *CompoundQueries) ([]gocb.SearchResultHit, error)
CompoundSearch apply the configuration of CompoundQueries and do the search then returns the hits
func (*Handler) CompoundSearchWithFacets ¶
func (h *Handler) CompoundSearchWithFacets(ctx context.Context, index string, q *CompoundQueries, facets []FacetDef) ([]gocb.SearchResultHit, map[string]gocb.SearchResultFacet, error)
CompoundSearchWithFacets apply the configuration of CompoundQueries and do the search then returns the hits and facets
func (*Handler) CountIndex ¶
func (*Handler) CreateFullTextSearchIndex ¶
func (h *Handler) CreateFullTextSearchIndex(ctx context.Context, def *IndexDefinition) error
CreateFullTextSearchIndex ...
func (*Handler) DeleteFullTextSearchIndex ¶
DeleteFullTextSearchIndex ...
func (*Handler) GetAndTouch ¶
func (h *Handler) GetAndTouch(ctx context.Context, typ, id string, ptr interface{}, ttl uint32) error
GetAndTouch retrieves a document and simultaneously updates its expiry times
func (*Handler) GetBulk ¶
func (h *Handler) GetBulk(ctx context.Context, hits []gocb.SearchResultHit, container interface{}) error
GetBulk accepts a set of hits from a search and a container represents the data-structure and fill it up with the hits where the container should be *[]T type
func (*Handler) GetManager ¶
func (h *Handler) GetManager(ctx context.Context) *gocb.BucketManager
GetManager returns a BucketManager for performing management operations on this bucket
func (*Handler) Index ¶
Index runs trough the given interface v and creates secondary indexes for all the with indexable:"true" tags
func (*Handler) Insert ¶
func (h *Handler) Insert(ctx context.Context, typ, id string, q interface{}, ttl uint32) (Cas, string, error)
Insert inserts a new record into couchbase bucket
func (*Handler) InspectFullTextSearchIndex ¶
func (h *Handler) InspectFullTextSearchIndex(ctx context.Context, indexName string) (bool, *IndexDefinition, error)
InspectFullTextSearchIndex checks the availability of the index and returns it if exists
func (*Handler) Ping ¶
func (h *Handler) Ping(ctx context.Context, services []gocb.ServiceType) (*gocb.PingReport, error)
Ping will ping a list of services and verify they are active and responding in an acceptable period of time
func (*Handler) RangeSearch ¶
func (h *Handler) RangeSearch(ctx context.Context, index string, q *RangeQuery) ([]gocb.SearchResultHit, error)
RangeSearch apply the configuration of RangeQuery and do the search then returns the hits
func (*Handler) RangeSearchWithFacets ¶
func (h *Handler) RangeSearchWithFacets(ctx context.Context, index string, q *RangeQuery, facets []FacetDef) ([]gocb.SearchResultHit, map[string]gocb.SearchResultFacet, error)
RangeSearchWithFacets apply the configuration of RangeQuery and do the search then returns the hits and facets
func (*Handler) SetDocumentType ¶
SetDocumentType adds the type of the given field to the state
func (*Handler) SimpleSearch ¶
func (h *Handler) SimpleSearch(ctx context.Context, index string, q *SearchQuery) ([]gocb.SearchResultHit, error)
SimpleSearch apply the configuration of SearchQuery and do the search then returns the hits
func (*Handler) SimpleSearchWithFacets ¶
func (h *Handler) SimpleSearchWithFacets(ctx context.Context, index string, q *SearchQuery, facets []FacetDef) ([]gocb.SearchResultHit, map[string]gocb.SearchResultFacet, error)
SimpleSearchWithFacets apply the configuration of SearchQuery and do the search then returns the hits and facets
func (*Handler) Touch ¶
Touch touches documents, specifying a new expiry time for it The Cas value must be 0
func (*Handler) Upsert ¶
func (h *Handler) Upsert(ctx context.Context, typ, id string, q interface{}, ttl uint32) (Cas, string, error)
Upsert inserts or replaces a document in the bucket
func (*Handler) ValidateState ¶
ValidateState validates the state of the bucket
type IndexCount ¶
type IndexCount struct { Status string `json:"status"` Count null.Uint `json:"count,omitempty"` Error null.String `json:"error,omitempty"` Request null.String `json:"request,omitempty"` }
IndexCount represents index count response
type IndexDefaultMapping ¶
IndexDefaultMapping ...
type IndexDefinition ¶
type IndexDefinition struct { Type string `json:"type"` Name string `json:"name"` UUID string `json:"uuid"` SourceType string `json:"sourceType"` SourceName string `json:"sourceName"` SourceUUID string `json:"sourceUUID"` SourceParams interface{} `json:"sourceParams"` // TODO PlanParams IndexPlanParams `json:"planParams"` Params IndexParams `json:"params"` }
IndexDefinition ...
func DefaultFullTextSearchIndexDefinition ¶
func DefaultFullTextSearchIndexDefinition(meta IndexMeta) (*IndexDefinition, error)
DefaultFullTextSearchIndexDefinition creates a default index def for full-text search and return it in purpose to change default values manually
type IndexDefs ¶
type IndexDefs struct { UUID string `json:"uuid"` IndexDefs map[string]IndexDefinition `json:"indexDefs"` }
IndexDefs ...
type IndexDocConfig ¶
type IndexDocConfig struct { DocIDPrefixDelimiter string `json:"docid_prefix_delim"` DocIDRegexp string `json:"docid_regexp"` Mode string `json:"mode"` TypeField string `json:"type_field"` }
IndexDocConfig ...
type IndexField ¶
type IndexField struct { Analyzer string `json:"analyzer"` IncludeInAll bool `json:"include_in_all"` IncludeTermVectors bool `json:"include_term_vectors"` Index bool `json:"index"` Name string `json:"name"` Store bool `json:"store"` Type string `json:"type"` }
IndexField ...
type IndexMapping ¶
type IndexMapping struct { DefaultAnalyzer string `json:"default_analyzer"` DefaultDatetimeParser string `json:"default_datetime_parser"` DefaultField string `json:"default_field"` DefaultMapping IndexDefaultMapping `json:"default_mapping"` DefaultType string `json:"default_type"` DocvaluesDynamic bool `json:"docvalues_dynamic"` IndexDynamic bool `json:"index_dynamic"` StoreDynamic bool `json:"store_dynamic"` TypeField string `json:"type_field"` Types map[string]IndexType `json:"types"` }
IndexMapping ...
type IndexMeta ¶
type IndexMeta struct { Name string SourceType string SourceName string DocIDPrefixDelimiter string DocIDRegexp string TypeField string }
IndexMeta ...
type IndexParams ¶
type IndexParams struct { DocConfig IndexDocConfig `json:"doc_config"` Mapping IndexMapping `json:"mapping"` Store IndexStore `json:"store"` }
IndexParams ...
type IndexPlanParams ¶
type IndexPlanParams struct { MaxPartitionsPerPIndex int64 `json:"maxPartitionsPerPIndex"` NumReplicas int64 `json:"numReplicas"` }
IndexPlanParams ...
type IndexProperties ¶
type IndexProperties struct { Dynamic bool `json:"dynamic"` Enabled bool `json:"enabled"` Fields []IndexField `json:"fields"` }
IndexProperties ...
type IndexStat ¶
type IndexStat struct { Status null.String `json:"status,omitempty"` Error null.String `json:"error,omitempty"` Request null.String `json:"request,omitempty"` AggStats null.JSON `json:"aggStats,omitempty"` DocCount null.Uint `json:"docCount,omitempty"` NodesStats null.JSON `json:"nodesStats"` }
IndexStat represents the statistics of the search index
type IndexStore ¶
type IndexStore struct { IndexType string `json:"indexType"` KVStoreName string `json:"kvStoreName"` }
IndexStore ...
type IndexType ¶
type IndexType struct { Dynamic bool `json:"dynamic"` Enabled bool `json:"enabled"` DefaultAnalyzer string `json:"default_analyzer,omitempty"` Properties map[string]IndexProperties `json:"properties"` }
IndexType ...
type NullTimeout ¶
NullTimeout is the library's built in NullTimeout type for Opts
func NullTimeoutFrom ¶
func NullTimeoutFrom(dur time.Duration) NullTimeout
NullTimeoutFrom creates a NullTimeout with the given time.Duration
func NullTimeoutMillisec ¶
func NullTimeoutMillisec(dur uint64) NullTimeout
NullTimeoutMillisec creates a NullTimeout with the given millisec
func NullTimeoutSec ¶
func NullTimeoutSec(dur uint64) NullTimeout
NullTimeoutSec creates a NullTimeout with the given sec
type Opts ¶
type Opts struct { OperationTimeout NullTimeout `json:"operation_timeout"` BulkOperationTimeout NullTimeout `json:"bulk_operation_timeout"` DurabilityTimeout NullTimeout `json:"durability_timeout"` DurabilityPollTimeout NullTimeout `json:"durability_poll_timeout"` ViewTimeout NullTimeout `json:"view_timeout"` N1qlTimeout NullTimeout `json:"n1ql_timeout"` AnalyticsTimeout NullTimeout `json:"analytics_timeout"` }
Opts is the couchbase related configuration such as timeouts
type RangeQuery ¶
type RangeQuery struct { StartAsTime time.Time `json:"-"` EndAsTime time.Time `json:"-"` Start string `json:"start,omitempty"` End string `json:"end,omitempty"` Min int64 `json:"min,omitempty"` Max int64 `json:"max,omitempty"` InclusiveStart bool `json:"inclusive_start,omitempty"` InclusiveEnd bool `json:"inclusive_end,omitempty"` InclusiveMin bool `json:"inclusive_min,omitempty"` InclusiveMax bool `json:"inclusive_max,omitempty"` Field string `json:"field,omitempty"` Limit int `json:"-"` Offset int `json:"-"` }
RangeQuery is a representation of the available search option for a RangeSearch
type SearchQuery ¶
type SearchQuery struct { Query string `json:"query,omitempty"` Match string `json:"match,omitempty"` MatchPhrase string `json:"match_phrase,omitempty"` Term string `json:"term,omitempty"` Prefix string `json:"prefix,omitempty"` Regexp string `json:"regexp,omitempty"` Wildcard string `json:"wildcard,omitempty"` Field string `json:"field,omitempty"` Analyzer string `json:"analyzer,omitempty"` Fuzziness int64 `json:"fuzziness,omitempty"` PrefixLength int64 `json:"prefix_length,omitempty"` Limit int `json:"-"` Offset int `json:"-"` }
SearchQuery is a representation of the available search option for a SimpleSearch