Documentation ¶
Overview ¶
Package grsearch is an extension to github.com/redis/go-redis, implementing support for RedisJSON and RediSearch. It attempts to follow the syntactic style of go-redis as closely as possible.
query provides an interface to RedisSearch's query functionality.
grsearch main module - defines the client class
Index ¶
- Constants
- Variables
- func FilterValue(val float64, exclusive bool) interface{}
- type AggregateApply
- type AggregateBuilder
- func (a *AggregateBuilder) Apply(expression, name string) *AggregateBuilder
- func (a *AggregateBuilder) Cursor(count uint64, timeout time.Duration) *AggregateBuilder
- func (a *AggregateBuilder) Dialect(version uint8) *AggregateBuilder
- func (a *AggregateBuilder) Filter(filter string) *AggregateBuilder
- func (a *AggregateBuilder) GroupBy(g AggregateGroupBy) *AggregateBuilder
- func (a *AggregateBuilder) Limit(offset, num int64) *AggregateBuilder
- func (a *AggregateBuilder) Load(name string, as string) *AggregateBuilder
- func (a *AggregateBuilder) LoadAll() *AggregateBuilder
- func (a *AggregateBuilder) Options() *AggregateOptions
- func (a *AggregateBuilder) Param(name string, value interface{}) *AggregateBuilder
- func (a *AggregateBuilder) Params(params map[string]interface{}) *AggregateBuilder
- func (a *AggregateBuilder) SortBy(keys []AggregateSortKey) *AggregateBuilder
- func (a *AggregateBuilder) SortByMax(keys []AggregateSortKey, max int64) *AggregateBuilder
- func (a *AggregateBuilder) Timeout(timeout time.Duration) *AggregateBuilder
- func (a *AggregateBuilder) Verbatim() *AggregateBuilder
- type AggregateCmd
- func (cmd *AggregateCmd) RESP3Data() *RESPData
- func (cmd *AggregateCmd) Result() ([]map[string]interface{}, error)
- func (cmd *AggregateCmd) SetRESP3Data(data *RESPData)
- func (cmd *AggregateCmd) SetTotalResults(n int64)
- func (cmd *AggregateCmd) SetVal(val []map[string]interface{})
- func (cmd *AggregateCmd) TotalResults() int64
- func (cmd *AggregateCmd) Val() []map[string]interface{}
- type AggregateCursor
- type AggregateFilter
- type AggregateGroupBy
- type AggregateLoad
- type AggregateOptions
- type AggregateReducer
- func ReduceAvg(property, as string) AggregateReducer
- func ReduceCount(as string) AggregateReducer
- func ReduceCountDistinct(property, as string) AggregateReducer
- func ReduceCountDistinctIsh(property, as string) AggregateReducer
- func ReduceFirstValue(property, order, as string) AggregateReducer
- func ReduceFirstValueBy(property, comparator, order, as string) AggregateReducer
- func ReduceMax(property, as string) AggregateReducer
- func ReduceMin(property, as string) AggregateReducer
- func ReduceQuantile(property string, quantile float64, as string) AggregateReducer
- func ReduceRandomSample(property string, sampleSize int64, as string) AggregateReducer
- func ReduceStdDev(property, as string) AggregateReducer
- func ReduceSum(property, as string) AggregateReducer
- func ReduceToList(property, as string) AggregateReducer
- type AggregateSort
- type AggregateSortKey
- type AggregateStep
- type Client
- func (c Client) FTAggregate(ctx context.Context, index, query string, options *AggregateOptions) *AggregateCmd
- func (c Client) FTAliasAdd(ctx context.Context, alias, index string) *redis.BoolCmd
- func (c Client) FTAliasDel(ctx context.Context, alias string) *redis.BoolCmd
- func (c Client) FTAliasUpdate(ctx context.Context, alias, index string) *redis.BoolCmd
- func (c Client) FTConfigGet(ctx context.Context, keys ...string) *ConfigGetCmd
- func (c Client) FTConfigSet(ctx context.Context, name, value string) *redis.BoolCmd
- func (c Client) FTCreate(ctx context.Context, index string, options *IndexOptions) *redis.BoolCmd
- func (c Client) FTDictAdd(ctx context.Context, dictionary string, terms ...string) *redis.IntCmd
- func (c Client) FTDictDel(ctx context.Context, dictionary string, terms ...string) *redis.IntCmd
- func (c Client) FTDictDump(ctx context.Context, dictionary string) *redis.StringSliceCmd
- func (c Client) FTDropIndex(ctx context.Context, index string, dropDocuments bool) *redis.BoolCmd
- func (c Client) FTInfo(ctx context.Context, index string) *InfoCmd
- func (c Client) FTList(ctx context.Context) *redis.StringSliceCmd
- func (c Client) FTSearchHash(ctx context.Context, index string, query string, qryOptions *QueryOptions) *QueryCmd
- func (c Client) FTSearchJSON(ctx context.Context, index string, query string, qryOptions *QueryOptions) *QueryCmd
- func (c Client) FTSynDump(ctx context.Context, index string) *SynonymDumpCmd
- func (c Client) FTSynUpdate(ctx context.Context, index string, group string, terms ...string) *redis.BoolCmd
- func (c Client) FTTagVals(ctx context.Context, index, tag string) *redis.StringSliceCmd
- func (c *Client) Process(ctx context.Context, cmd redis.Cmder) error
- type ConfigGetCmd
- type ExtCmder
- type GeoAttribute
- type GeoFilter
- type GeometryAttribute
- type GroupByBuilder
- type IndexBuilder
- func (i *IndexBuilder) Filter(filter string) *IndexBuilder
- func (i *IndexBuilder) Language(language string) *IndexBuilder
- func (i *IndexBuilder) LanguageField(field string) *IndexBuilder
- func (i *IndexBuilder) MaxTextFields() *IndexBuilder
- func (i *IndexBuilder) NoFields() *IndexBuilder
- func (i *IndexBuilder) NoFreqs() *IndexBuilder
- func (i *IndexBuilder) NoHighlight() *IndexBuilder
- func (i *IndexBuilder) NoOffsets() *IndexBuilder
- func (i *IndexBuilder) On(idxType string) *IndexBuilder
- func (a *IndexBuilder) Options() *IndexOptions
- func (i *IndexBuilder) Prefix(prefix string) *IndexBuilder
- func (i *IndexBuilder) Schema(t SchemaAttribute) *IndexBuilder
- func (i *IndexBuilder) Score(score float64) *IndexBuilder
- func (i *IndexBuilder) ScoreField(field string) *IndexBuilder
- func (i *IndexBuilder) SkipInitialscan() *IndexBuilder
- func (i *IndexBuilder) StopWord(word string) *IndexBuilder
- func (i *IndexBuilder) Temporary(secs uint64) *IndexBuilder
- type IndexOptions
- type Info
- type InfoCmd
- type IntSlicePointerCmd
- type Limit
- type NumericAttribute
- type QueryBuilder
- func (q *QueryBuilder) Ascending() *QueryBuilder
- func (q *QueryBuilder) Descending() *QueryBuilder
- func (q *QueryBuilder) Dialect(version uint8) *QueryBuilder
- func (q *QueryBuilder) ExplainScore() *QueryBuilder
- func (q *QueryBuilder) Filter(attribute string, min, max interface{}) *QueryBuilder
- func (q *QueryBuilder) GeoFilter(attribute string, long, lat, radius float64, units string) *QueryBuilder
- func (q *QueryBuilder) Highlight(fields []string) *QueryBuilder
- func (q *QueryBuilder) InField(field string) *QueryBuilder
- func (q *QueryBuilder) InKeys(keys []string) *QueryBuilder
- func (q *QueryBuilder) Limit(first int64, num int64) *QueryBuilder
- func (q *QueryBuilder) NoContent() *QueryBuilder
- func (q *QueryBuilder) NoStopWords() *QueryBuilder
- func (a *QueryBuilder) Options() *QueryOptions
- func (q *QueryBuilder) Param(name string, value interface{}) *QueryBuilder
- func (q *QueryBuilder) Params(params map[string]interface{}) *QueryBuilder
- func (q *QueryBuilder) Return(identifier string, alias string) *QueryBuilder
- func (q *QueryBuilder) Slop(slop int8) *QueryBuilder
- func (q *QueryBuilder) SortBy(field string) *QueryBuilder
- func (q *QueryBuilder) Summarize(fields []string, separator string, length, fragments int32) *QueryBuilder
- func (q *QueryBuilder) Timeout(timeout time.Duration) *QueryBuilder
- func (q *QueryBuilder) Verbatim() *QueryBuilder
- func (q *QueryBuilder) WithPayloads() *QueryBuilder
- func (q *QueryBuilder) WithScores() *QueryBuilder
- type QueryCmd
- func (cmd *QueryCmd) Count() int64
- func (cmd *QueryCmd) Iterator(ctx context.Context) *SearchIterator
- func (cmd *QueryCmd) Key(key string) *SearchResult
- func (cmd *QueryCmd) Keys() []string
- func (cmd *QueryCmd) Len() int64
- func (cmd *QueryCmd) RESP3Data() *RESPData
- func (cmd *QueryCmd) Result() ([]*SearchResult, error)
- func (cmd *QueryCmd) SetCount(count int64)
- func (cmd *QueryCmd) SetRESP3Data(data *RESPData)
- func (cmd *QueryCmd) SetTotalResults(r int64)
- func (cmd *QueryCmd) SetVal(val []*SearchResult)
- func (cmd *QueryCmd) String() string
- func (cmd *QueryCmd) TotalResults() int64
- func (cmd *QueryCmd) Val() []*SearchResult
- type QueryFilter
- type QueryHighlight
- type QueryOptions
- type QueryReturn
- type QuerySummarize
- type RESPData
- type SchemaAttribute
- type SearchCmdAble
- type SearchIterator
- type SearchResult
- type SynonymDumpCmd
- type TagAttribute
- type TextAttribute
- type VectorAttribute
Constants ¶
const ( DefaultOffset = 0 // default first value for return offset DefaultLimit = 10 // default number of results to return GeoMiles = "mi" GeoFeet = "f" GeoKilimetres = "km" GeoMetres = "m" SortAsc = "ASC" SortDesc = "DESC" SortNone = "" // SortNone is used to indicate that no sorting is required if you want be explicit )
Variables ¶
var LoadAll = AggregateLoad{Name: "*"}
LoadAll can be used to indicate FT.AGGREGATE idx LOAD *
Functions ¶
func FilterValue ¶
FilterValue formats a value for use in a filter and returns it
Types ¶
type AggregateApply ¶
type AggregateBuilder ¶
type AggregateBuilder struct {
// contains filtered or unexported fields
}
func NewAggregateBuilder ¶
func NewAggregateBuilder() *AggregateBuilder
NewAggregateBuilder creats a new fluid builder for aggregates
func (*AggregateBuilder) Apply ¶
func (a *AggregateBuilder) Apply(expression, name string) *AggregateBuilder
Apply appends a transform to the apply list
func (*AggregateBuilder) Cursor ¶
func (a *AggregateBuilder) Cursor(count uint64, timeout time.Duration) *AggregateBuilder
WithCursor creates a cursor for the aggregate to scan parts of the result
func (*AggregateBuilder) Dialect ¶
func (a *AggregateBuilder) Dialect(version uint8) *AggregateBuilder
Dialect sets the dialect option for the aggregate. It is NOT checked.
func (*AggregateBuilder) Filter ¶
func (a *AggregateBuilder) Filter(filter string) *AggregateBuilder
Filter adds a result filter
func (*AggregateBuilder) GroupBy ¶
func (a *AggregateBuilder) GroupBy(g AggregateGroupBy) *AggregateBuilder
GroupBy adds a new group by statement (constructed with a GroupByBuilder)
func (*AggregateBuilder) Limit ¶
func (a *AggregateBuilder) Limit(offset, num int64) *AggregateBuilder
Limit sets the result limit
func (*AggregateBuilder) Load ¶
func (a *AggregateBuilder) Load(name string, as string) *AggregateBuilder
Load adds a field to the load list for the aggregate. The alias can be the empty string.
func (*AggregateBuilder) LoadAll ¶
func (a *AggregateBuilder) LoadAll() *AggregateBuilder
LoadAll sets the load list for this aggregate to "LOAD *".
func (*AggregateBuilder) Options ¶
func (a *AggregateBuilder) Options() *AggregateOptions
Options returns the options struct built with the builder
func (*AggregateBuilder) Param ¶
func (a *AggregateBuilder) Param(name string, value interface{}) *AggregateBuilder
Param sets the value of a aggregate parameter.
func (*AggregateBuilder) Params ¶
func (a *AggregateBuilder) Params(params map[string]interface{}) *AggregateBuilder
Params sets all current parameters
func (*AggregateBuilder) SortBy ¶
func (a *AggregateBuilder) SortBy(keys []AggregateSortKey) *AggregateBuilder
SortBy adds a sorting step to this aggregate.
func (*AggregateBuilder) SortByMax ¶
func (a *AggregateBuilder) SortByMax(keys []AggregateSortKey, max int64) *AggregateBuilder
SortByMax sets the MAX limit on an aggregate sort key. This will be ignored if not sort keys have been supplied.
func (*AggregateBuilder) Timeout ¶
func (a *AggregateBuilder) Timeout(timeout time.Duration) *AggregateBuilder
Timeout sets the timeout for the aggregate, overriding the default
func (*AggregateBuilder) Verbatim ¶
func (a *AggregateBuilder) Verbatim() *AggregateBuilder
Verbatim sets the verbatim flag, disabling stemming
type AggregateCmd ¶
type AggregateCmd struct { redis.Cmd // contains filtered or unexported fields }
func NewAggregateCmd ¶
func NewAggregateCmd(ctx context.Context, args ...interface{}) *AggregateCmd
func (*AggregateCmd) RESP3Data ¶ added in v0.5.1
func (cmd *AggregateCmd) RESP3Data() *RESPData
RESPData returns the additional data returned with a RESP3 response if set.
func (*AggregateCmd) Result ¶
func (cmd *AggregateCmd) Result() ([]map[string]interface{}, error)
func (*AggregateCmd) SetRESP3Data ¶ added in v0.5.1
func (cmd *AggregateCmd) SetRESP3Data(data *RESPData)
SetRESPData stores the additional data returned with a RESP3 response if set.
func (*AggregateCmd) SetTotalResults ¶ added in v0.5.1
func (cmd *AggregateCmd) SetTotalResults(n int64)
func (*AggregateCmd) SetVal ¶
func (cmd *AggregateCmd) SetVal(val []map[string]interface{})
func (*AggregateCmd) TotalResults ¶ added in v0.5.1
func (cmd *AggregateCmd) TotalResults() int64
func (*AggregateCmd) Val ¶
func (cmd *AggregateCmd) Val() []map[string]interface{}
type AggregateCursor ¶
type AggregateFilter ¶
type AggregateFilter string
type AggregateGroupBy ¶
type AggregateGroupBy struct { Properties []string Reducers []AggregateReducer }
AggregateGroupBy represents a single GROUPBY statement in a
type AggregateLoad ¶
Load represents parameters to the LOAD argument
type AggregateOptions ¶
type AggregateOptions struct { Verbatim bool // Set to true if stemming should not be used Load []AggregateLoad // Values for the LOAD subcommand; use the [LoadAll] variable to represent "LOAD *" Timeout time.Duration // Sets the query timeout. If zero, no TIMEOUT subcommmand is used Cursor *AggregateCursor // nil means no cursor Params map[string]interface{} Dialect uint8 Steps []AggregateStep // The steps to be executed in order }
AggregateOptions represents the options that can be passed to [FT.AGGREGATE]. This can be built by calling the NewAggregateOptions function or via [AggregateOptionsBuilder.Options] using the Builder API.
func NewAggregateOptions ¶
func NewAggregateOptions() *AggregateOptions
NewAggregateOptions creates a new query with defaults set
type AggregateReducer ¶
func ReduceAvg ¶
func ReduceAvg(property, as string) AggregateReducer
ReduceAvg returns a Reducer configured to return the mean value of the given property.
func ReduceCount ¶
func ReduceCount(as string) AggregateReducer
ReduceCount returns a Reducer configured to count records
func ReduceCountDistinct ¶
func ReduceCountDistinct(property, as string) AggregateReducer
ReduceCountDistinct returns a Reducer configured to count distinct values of a property
func ReduceCountDistinctIsh ¶
func ReduceCountDistinctIsh(property, as string) AggregateReducer
ReduceCountDistinctIsh returns a Reducer configured to count distinct values of a property approximately
func ReduceFirstValue ¶
func ReduceFirstValue(property, order, as string) AggregateReducer
ReduceFirstValue returns a Reducer configured to get the first value of a given property with optional sorting.
func ReduceFirstValueBy ¶
func ReduceFirstValueBy(property, comparator, order, as string) AggregateReducer
ReduceFirstValue returns a Reducer configured to get the first value of a given property with optional sorting using another property as the comparator
func ReduceMax ¶
func ReduceMax(property, as string) AggregateReducer
ReduceMax returns a Reducer configured to return the maximum value of the given property.
func ReduceMin ¶
func ReduceMin(property, as string) AggregateReducer
ReduceMin returns a Reducer configured to return the minimum value of the given property.
func ReduceQuantile ¶
func ReduceQuantile(property string, quantile float64, as string) AggregateReducer
ReduceAvg returns a Reducer configured to return the mean value of the given property.
func ReduceRandomSample ¶
func ReduceRandomSample(property string, sampleSize int64, as string) AggregateReducer
ReduceRandomSample returns a Reducder configured to perform a random sampling of values of the property with a given sample size
func ReduceStdDev ¶
func ReduceStdDev(property, as string) AggregateReducer
ReduceAvg returns a Reducer configured to return the mean value of the given property.
func ReduceSum ¶
func ReduceSum(property, as string) AggregateReducer
ReduceSum returns a Reducer configured to return the sum of the values of the given property.
func ReduceToList ¶
func ReduceToList(property, as string) AggregateReducer
ReduceToList returns a reducer configured to merge all distinct values of the property into an array
type AggregateSort ¶
type AggregateSort struct { Keys []AggregateSortKey Max int64 }
type AggregateSortKey ¶
type AggregateStep ¶
type AggregateStep interface {
// contains filtered or unexported methods
}
type Client ¶
type Client struct { redis.Client // contains filtered or unexported fields }
Client represents the wrapped go-redis client. New clients should be created using NewClient
func FromRedisClient ¶ added in v0.5.3
func FromRedisClient(redisClient *redis.Client) *Client
FromRedisClient builds a client from an existing redis client
func NewClient ¶
func NewClient(options *redis.Options) *Client
NewClient returns a new search client using the same options as the standard go-redis client.
func (Client) FTAggregate ¶
func (c Client) FTAggregate(ctx context.Context, index, query string, options *AggregateOptions) *AggregateCmd
FTAggregate runs a search query on an index, and perform saggregate transformations on the results, extracting statistics etc from them
func (Client) FTAliasAdd ¶
FTAliasAdd add an alias to an index.
func (Client) FTAliasDel ¶
FTAliasDel deletes an alias
func (Client) FTAliasUpdate ¶
FTAliasDel deletes an alias
func (Client) FTConfigGet ¶
func (c Client) FTConfigGet(ctx context.Context, keys ...string) *ConfigGetCmd
FTConfigGet retrieves public config info from the search config
func (Client) FTConfigSet ¶
FTConfigGet sets values in the search config
func (Client) FTCreate ¶
func (c Client) FTCreate(ctx context.Context, index string, options *IndexOptions) *redis.BoolCmd
FTCreate creates a new index.
func (Client) FTDictDump ¶
FTDictDump returns a slice containing all the terms in a dictionary
func (Client) FTDropIndex ¶
FTDropIndex removes an index, optionally dropping documents in the index.
func (Client) FTSearchHash ¶ added in v0.4.0
func (c Client) FTSearchHash(ctx context.Context, index string, query string, qryOptions *QueryOptions) *QueryCmd
FTSearch queries an index (on hashes)
func (Client) FTSearchJSON ¶
func (c Client) FTSearchJSON(ctx context.Context, index string, query string, qryOptions *QueryOptions) *QueryCmd
FTSearch queries an index on JSON documents
func (Client) FTSynDump ¶
func (c Client) FTSynDump(ctx context.Context, index string) *SynonymDumpCmd
FTSynDump returns the contents of synonym map for an index
func (Client) FTSynUpdate ¶
func (c Client) FTSynUpdate(ctx context.Context, index string, group string, terms ...string) *redis.BoolCmd
FTSynUpdate adds to or modifies a synonym group
type ConfigGetCmd ¶
type ConfigGetCmd struct { redis.Cmd // contains filtered or unexported fields }
func NewConfigGetCmd ¶
func NewConfigGetCmd(ctx context.Context, args ...interface{}) *ConfigGetCmd
func (*ConfigGetCmd) SetVal ¶
func (cmd *ConfigGetCmd) SetVal(val map[string]string)
func (*ConfigGetCmd) Val ¶
func (cmd *ConfigGetCmd) Val() map[string]string
type GeoAttribute ¶
type GeometryAttribute ¶
type GroupByBuilder ¶
type GroupByBuilder struct {
// contains filtered or unexported fields
}
func NewGroupByBuilder ¶
func NewGroupByBuilder() *GroupByBuilder
NewGroupByBuilder creates a builder for group by statements in aggregates.
func (*GroupByBuilder) GroupBy ¶
func (g *GroupByBuilder) GroupBy() AggregateGroupBy
GroupBy returns the grouping defined by the builder
func (*GroupByBuilder) Properties ¶
func (g *GroupByBuilder) Properties(properties []string) *GroupByBuilder
Properties sets all the property for a group by at one time.
func (*GroupByBuilder) Property ¶
func (g *GroupByBuilder) Property(name string) *GroupByBuilder
Property appends a property to the properties list, not adding it if it already exists
func (*GroupByBuilder) Reduce ¶
func (g *GroupByBuilder) Reduce(r AggregateReducer) *GroupByBuilder
Reduce adds a reducer function to the group by.
type IndexBuilder ¶
type IndexBuilder struct {
// contains filtered or unexported fields
}
func NewIndexBuilder ¶
func NewIndexBuilder() *IndexBuilder
NewIndexBuilder creats a new fluid builder for indexes
func (*IndexBuilder) Filter ¶
func (i *IndexBuilder) Filter(filter string) *IndexBuilder
Filter sets the IndexOptions' Filter field to the provided value
func (*IndexBuilder) Language ¶
func (i *IndexBuilder) Language(language string) *IndexBuilder
Language sets the IndexOptions' Language field to the provided value, setting the default language for the index
func (*IndexBuilder) LanguageField ¶
func (i *IndexBuilder) LanguageField(field string) *IndexBuilder
LanguageField sets the IndexOptions' LanguageField field to the provided value, setting the field definining language in the index
func (*IndexBuilder) MaxTextFields ¶
func (i *IndexBuilder) MaxTextFields() *IndexBuilder
MaxTextFields sets the IndexOptions' MaxTextFields field to true
func (*IndexBuilder) NoFields ¶
func (i *IndexBuilder) NoFields() *IndexBuilder
NoFields sets the IndexOptions' NoFields field to true
func (*IndexBuilder) NoFreqs ¶
func (i *IndexBuilder) NoFreqs() *IndexBuilder
NoFreqs sets the IndexOptions' NoFreqs field to true.
func (*IndexBuilder) NoHighlight ¶
func (i *IndexBuilder) NoHighlight() *IndexBuilder
NoHighlight sets the IndexOptions' NoHighlight field to true
func (*IndexBuilder) NoOffsets ¶
func (i *IndexBuilder) NoOffsets() *IndexBuilder
NoOffsets sets the IndexOptions' NoOffsets field to true
func (*IndexBuilder) On ¶
func (i *IndexBuilder) On(idxType string) *IndexBuilder
On indicates if the index is on hashes (default) or json
func (*IndexBuilder) Options ¶
func (a *IndexBuilder) Options() *IndexOptions
Options returns the options struct built with the builder
func (*IndexBuilder) Prefix ¶
func (i *IndexBuilder) Prefix(prefix string) *IndexBuilder
Prefix appends a prefix to the IndexOptions' Prefix array
func (*IndexBuilder) Schema ¶
func (i *IndexBuilder) Schema(t SchemaAttribute) *IndexBuilder
Schema appends a schema attribute to the IndexOptions' Schema array
func (*IndexBuilder) Score ¶
func (i *IndexBuilder) Score(score float64) *IndexBuilder
Score sets the IndexOptions' Score field to the provided value, setting the default score for documents (this should be zero to 1.0 and is not checked)
func (*IndexBuilder) ScoreField ¶
func (i *IndexBuilder) ScoreField(field string) *IndexBuilder
ScoreField sets the IndexOptions' ScoreField field to the provided value, setting the field defining document score in the index
func (*IndexBuilder) SkipInitialscan ¶
func (i *IndexBuilder) SkipInitialscan() *IndexBuilder
SkipInitialscan sets the IndexOptions' SkipInitialscan field to true.
func (*IndexBuilder) StopWord ¶
func (i *IndexBuilder) StopWord(word string) *IndexBuilder
topWord appends a new stopword to the IndexOptions' stopwords array and sets UseStopWords to true
func (*IndexBuilder) Temporary ¶
func (i *IndexBuilder) Temporary(secs uint64) *IndexBuilder
Temporary sets the Temporary field to the given number of seconds.
type IndexOptions ¶
type IndexOptions struct { On string Prefix []string Filter string Language string LanguageField string Score float64 ScoreField string MaxTextFields bool NoOffsets bool Temporary uint64 // If this is a temporary index, number of seconds until expiry NoHighlight bool NoFields bool NoFreqs bool StopWords []string UseStopWords bool SkipInitialscan bool Schema []SchemaAttribute }
SearchIndex defines an index to be created with FT.CREATE
func NewIndexOptions ¶
func NewIndexOptions() *IndexOptions
NewIndexOptions returns an initialised IndexOptions struct with defaults set
type Info ¶
type Info struct { IndexName string Index *IndexOptions NumDocs int64 MaxDocId int64 NumTerms int64 NumRecords int64 Indexing float64 PercentIndexed float64 HashIndexingFailures int64 TotalInvertedIndexBlocks int64 InvertedSize float64 VectorIndexSize float64 DocTableSize float64 OffsetVectorsSize float64 SortableValuesSize float64 KeyTableSize float64 AverageRecordsPerDoc float64 AverageBytesPerRecord float64 AverageOffsetsPerTerm float64 AverageOffsetBitsPerRecord float64 TotalIndexingTime time.Duration NumberOfUses int64 GCStats struct { BytesCollected int64 TotalMsRun time.Duration TotalCycles int64 AverageCycleTime time.Duration LastRunTime time.Duration GCNumericTreesMissed int64 GCBlocksDenied int64 } CursorStats struct { GlobalIdle int64 GlobalTotal int64 IndexCapacity int64 IndexTotal int64 } DialectStats struct { Dialect1 int64 Dialect2 int64 Dialect3 int64 } }
Info represents the parsed results of a call to FT.INFO.
type InfoCmd ¶
type InfoCmd struct { redis.Cmd // contains filtered or unexported fields }
func NewInfoCmd ¶
type IntSlicePointerCmd ¶
type IntSlicePointerCmd struct { redis.SliceCmd // contains filtered or unexported fields }
func NewIntSlicePointerCmd ¶
func NewIntSlicePointerCmd(ctx context.Context, args ...interface{}) *IntSlicePointerCmd
NewIntSlicePointerCmd initialises an IntSlicePointerCmd
func (*IntSlicePointerCmd) Result ¶
func (cmd *IntSlicePointerCmd) Result() ([]*int64, error)
func (*IntSlicePointerCmd) SetVal ¶
func (cmd *IntSlicePointerCmd) SetVal(val []*int64)
func (*IntSlicePointerCmd) Val ¶
func (cmd *IntSlicePointerCmd) Val() []*int64
type NumericAttribute ¶
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
func NewQueryBuilder ¶
func NewQueryBuilder() *QueryBuilder
NewAggregateBuilder creats a new fluid builder for aggregates
func (*QueryBuilder) Ascending ¶
func (q *QueryBuilder) Ascending() *QueryBuilder
Ascending sets the sort order of the query results to ascending if sortby is set
func (*QueryBuilder) Descending ¶
func (q *QueryBuilder) Descending() *QueryBuilder
Descending sets the sort order of the query results to ascending if sortby is set
func (*QueryBuilder) Dialect ¶
func (q *QueryBuilder) Dialect(version uint8) *QueryBuilder
Dialect sets the dialect option for the query. It is NOT checked.
func (*QueryBuilder) ExplainScore ¶
func (q *QueryBuilder) ExplainScore() *QueryBuilder
ExplainScore sets the EXPLAINSCORE option for searches.
func (*QueryBuilder) Filter ¶
func (q *QueryBuilder) Filter(attribute string, min, max interface{}) *QueryBuilder
Filter adds a filter to the current set
func (*QueryBuilder) GeoFilter ¶
func (q *QueryBuilder) GeoFilter(attribute string, long, lat, radius float64, units string) *QueryBuilder
GeoFilter adds a geographic filter to the query
func (*QueryBuilder) Highlight ¶
func (q *QueryBuilder) Highlight(fields []string) *QueryBuilder
Highlight sets the Highlight member of the query
func (*QueryBuilder) InField ¶
func (q *QueryBuilder) InField(field string) *QueryBuilder
InFields adds a field to the INFIELDS list limiting the search to only the given fields.
func (*QueryBuilder) InKeys ¶
func (q *QueryBuilder) InKeys(keys []string) *QueryBuilder
InKeys sets the keys to be searched, limiting the search to only these keys.
func (*QueryBuilder) Limit ¶
func (q *QueryBuilder) Limit(first int64, num int64) *QueryBuilder
Limit adds a limit to a query, returning the Query with the limit added (to allow chaining)
func (*QueryBuilder) NoContent ¶
func (q *QueryBuilder) NoContent() *QueryBuilder
NoContent sets the NoContent flag to true.
func (*QueryBuilder) NoStopWords ¶
func (q *QueryBuilder) NoStopWords() *QueryBuilder
NoStopWords disables stop word checking
func (*QueryBuilder) Options ¶
func (a *QueryBuilder) Options() *QueryOptions
Options returns the options struct built with the builder
func (*QueryBuilder) Param ¶
func (q *QueryBuilder) Param(name string, value interface{}) *QueryBuilder
Param sets or adds the value of a query parameter.
func (*QueryBuilder) Params ¶
func (q *QueryBuilder) Params(params map[string]interface{}) *QueryBuilder
Params sets the current set parameters
func (*QueryBuilder) Return ¶
func (q *QueryBuilder) Return(identifier string, alias string) *QueryBuilder
Return appends a field to the return fields list
func (*QueryBuilder) Slop ¶
func (q *QueryBuilder) Slop(slop int8) *QueryBuilder
Slop sets the slop length.
func (*QueryBuilder) SortBy ¶
func (q *QueryBuilder) SortBy(field string) *QueryBuilder
SortBy sets the value of the sortby option to the query.
func (*QueryBuilder) Summarize ¶
func (q *QueryBuilder) Summarize(fields []string, separator string, length, fragments int32) *QueryBuilder
Summarize sets the Summarize member of the query,
func (*QueryBuilder) Timeout ¶
func (q *QueryBuilder) Timeout(timeout time.Duration) *QueryBuilder
WithTimeout sets the timeout for the query, overriding the default
func (*QueryBuilder) Verbatim ¶
func (q *QueryBuilder) Verbatim() *QueryBuilder
Verbatim disables stemming.
func (*QueryBuilder) WithPayloads ¶
func (q *QueryBuilder) WithPayloads() *QueryBuilder
WithPayloads sets the WITHPAYLOADS option for searches
func (*QueryBuilder) WithScores ¶
func (q *QueryBuilder) WithScores() *QueryBuilder
WithScores sets the WITHSCORES option for searches
type QueryCmd ¶
type QueryCmd struct { redis.Cmd // contains filtered or unexported fields }
func NewQueryCmd ¶
NewQueryCmd returns an initialised query command.
func (*QueryCmd) Iterator ¶
func (cmd *QueryCmd) Iterator(ctx context.Context) *SearchIterator
Iterator returns an iterator for the search.
func (*QueryCmd) Key ¶ added in v0.5.0
func (cmd *QueryCmd) Key(key string) *SearchResult
Key returns the individual result with the given key
func (*QueryCmd) RESP3Data ¶ added in v0.5.0
RESPData returns the additional data returned with a RESP3 response if set.
func (*QueryCmd) Result ¶
func (cmd *QueryCmd) Result() ([]*SearchResult, error)
func (*QueryCmd) SetRESP3Data ¶ added in v0.5.0
SetRESPData stores the additional data returned with a RESP3 response if set.
func (*QueryCmd) SetTotalResults ¶ added in v0.5.0
SetTotalResults store the total number of possible results for the query.
func (*QueryCmd) SetVal ¶
func (cmd *QueryCmd) SetVal(val []*SearchResult)
func (*QueryCmd) TotalResults ¶ added in v0.5.0
TotalResults returns the total number of possible results for the query (whilst Count returns the number of results from a single call to FTSEearch)
func (*QueryCmd) Val ¶
func (cmd *QueryCmd) Val() []*SearchResult
type QueryFilter ¶
type QueryFilter struct { Attribute string Min interface{} // either a numeric value or +inf, -inf or "(" followed by numeric Max interface{} // as above }
func NewQueryFilter ¶
func NewQueryFilter(attribute string) QueryFilter
NewQueryFilter returns a filter with the min and max properties to set + and - infinity.
type QueryHighlight ¶
QueryHighlight allows the user to define optional query highlighting
func NewQueryHighlight ¶
func NewQueryHighlight() *QueryHighlight
type QueryOptions ¶
type QueryOptions struct { NoContent bool Verbatim bool NoStopWords bool WithScores bool WithPayloads bool WithSortKeys bool InOrder bool ExplainScore bool Limit *Limit Return []QueryReturn Filters []QueryFilter InKeys []string InFields []string Language string Slop int8 Expander string Scorer string SortBy string SortOrder string Dialect uint8 Timeout time.Duration Summarize *QuerySummarize HighLight *QueryHighlight GeoFilters []GeoFilter Params map[string]interface{} // contains filtered or unexported fields }
func NewQueryOptions ¶
func NewQueryOptions() *QueryOptions
NewQuery creates a new query with defaults set
type QueryReturn ¶
type QuerySummarize ¶
func DefaultQuerySummarize ¶
func DefaultQuerySummarize() *QuerySummarize
func NewQuerySummarize ¶
func NewQuerySummarize() *QuerySummarize
type RESPData ¶ added in v0.5.0
type RESPData struct { Errors []interface{} Warnings []interface{} Format string Attributes []interface{} }
type SchemaAttribute ¶
type SchemaAttribute interface {
// contains filtered or unexported methods
}
type SearchCmdAble ¶
type SearchCmdAble interface { FTSearch(ctx context.Context, index string, query string, options *QueryOptions) *QueryCmd FTAggregate(ctx context.Context, index string, query string, options *AggregateOptions) *QueryCmd FTDropIndex(ctx context.Context, index string, dropDocuments bool) *redis.BoolCmd FTCreateIndex(ctx context.Context, index string) FTConfigGet(ctx context.Context, keys ...string) *ConfigGetCmd FTConfigSet(ctx context.Context, name, value string) *redis.BoolCmd FTTagVals(ctx context.Context, index, tag string) *redis.StringSliceCmd FTList(ctx context.Context) *redis.StringSliceCmd FTInfo(ctx context.Context, index string) *InfoCmd FTDictAdd(ctx context.Context, dictionary string, terms ...string) *redis.IntCmd FTDictDel(ctx context.Context, dictionary string, terms ...string) *redis.IntCmd FTDictDump(ctx context.Context, dictionary string) *redis.StringSliceCmd FTSynUpdate(ctx context.Context, index string, group string, terms ...string) *redis.BoolCmd FTSynDump(ctx context.Context, index string) *SynonymDumpCmd FTAliasAdd(ctx context.Context, alias, index string) *redis.BoolCmd FTAliasDel(ctx context.Context, alias string) *redis.BoolCmd FTAliasUpdate(ctx context.Context, alias, index string) *redis.BoolCmd }
type SearchIterator ¶
type SearchIterator struct {
// contains filtered or unexported fields
}
SearchIterator is used to incrementally iterate over a collection of elements.
func NewSearchIterator ¶
func NewSearchIterator(ctx context.Context, cmd *QueryCmd, process cmdable) *SearchIterator
NewSearchIterator returns a configured iterator for QueryCmd
func (*SearchIterator) Err ¶
func (it *SearchIterator) Err() error
Err returns the last iterator error, if any.
func (*SearchIterator) Next ¶
func (it *SearchIterator) Next(ctx context.Context) bool
Next advances the cursor and returns true if more values can be read.
func (*SearchIterator) Val ¶
func (it *SearchIterator) Val() *SearchResult
Val returns the key/field at the current cursor position.
type SearchResult ¶ added in v0.5.0
type SearchResult struct { Key string Score float64 Explanation interface{} Values map[string]string }
func (*SearchResult) UnMarshal ¶ added in v0.5.0
func (q *SearchResult) UnMarshal(key string, target interface{}) error
UnMarshal is a simple wrapper around encoding/JSON to simplify the retrieval of JSON results.
type SynonymDumpCmd ¶
type SynonymDumpCmd struct { redis.Cmd // contains filtered or unexported fields }
func NewSynonymDumpCmd ¶
func NewSynonymDumpCmd(ctx context.Context, args ...interface{}) *SynonymDumpCmd
func (*SynonymDumpCmd) SetVal ¶
func (cmd *SynonymDumpCmd) SetVal(val map[string][]string)
func (*SynonymDumpCmd) Val ¶
func (cmd *SynonymDumpCmd) Val() map[string][]string