RediSearch Documentation

Public Functions

These functions are exported by RediSearch.

RediSearch.FieldType
Field::AbstractField(
    name::String
    args::Vector{Union{String,Number}}
    sortable::Bool
    no_index::Bool
    as_name::Union{String,Nothing}
)

Field object to include in RediSearch schema.

Arguments

  • name::String: Name of the field.

KeyWords

  • args::Vector{Union{String,Number}}: List of Arguments fot the field.
  • sortable::Bool: Sortable status.
  • no_index::Bool: Index Status.
  • as_name::Union{String,Nothing}: Name to reference field as.

Returns

  • Field::AbstractField
source
RediSearch.IndexDefinitionType
IndexDefinition(args)

Object used to create a specific index in Redis.

Fields

  • args::Vector{Union{String,Number}}: List of arguments used to define a searchable index.
source
RediSearch.IndexDefinitionMethod
IndexDefinition(;
    prefix=[],
    filter="",
    language_field="",
    language="",
    score_field="",
    score=1.0,
    payload_field="",
    index_type=IndexType.HASH
) -> IndexDefinition

IndexDefinition is used to define a index definition for automatic indexing on Hash or Json update.

KeyWords

  • prefix::AbstractArray{AbstractString}: Tells the index which keys it should index. Each

prefix should finish with a :.

  • filter::AbstractString: Filter expression with the full RediSearch aggregation

expression language.

  • language_field::AbstractString: If set indicates the document attribute that should be

used as the document language.

  • language::AbstractString: If set indicates the default language for documents in the

index. Default to English.

  • score_field::AbstractString: If set indicates the document attribute that should be used

as the document's rank based on the user's ranking. Ranking must be between 0.0 and 1.0. If not set the default score is 1

  • score::Float64: If set indicates the default score for documents in the index.

Default score is 1.0.

  • payload_field::AbstractString: If set indicates the document attribute that should be

used as a binary safe payload string to the document, that can be evaluated at query time by a custom scoring function, or retrieved to the client.

  • index_type::Number: Currently supports HASH (default) and JSON.
source
RediSearch.QueryType
Query(
    query_string::AbstractString;
    offset = 0,
    num = 10,
    no_content = false,
    no_stopwords = false,
    fields = [],
    verbatim = false,
    with_payloads = false,
    with_scores = false,
    scorer = nothing,
    filters = [],
    ids = [],
    slop = -1,
    in_order = false,
    sortby = nothing,
    return_fields = [],
    summarize_fields = [],
    highlight_fields = [],
    language = nothing
)::Query

Creates a query instance that can be used to search a RediSearch instance

Arguments

  • query_string::String

KeyWords

  • offset::Integer
  • num::Integer
  • no_content::Bool
  • no_stopwords::Bool
  • fields::AbstractArray
  • verbatim::Boolverbatim setting for
  • with_payloads::Bool
  • with_scores::Bool
  • scorer::Union{String, Nothing}
  • filters::AbstractArray{AbstractFilter}
  • ids::AbstractArray
  • slop::Integer
  • in_order::Bool
  • sortby::Union{AbstractFilter, Nothing}
  • return_fields::AbstractArray
  • summarize_fields::AbstractArray
  • highlight_fields::AbstractArray
  • language::Union{String, Nothing}

Returns

  • Query::AbstractQuery
source
RediSearch.SearchClientType
Client(index_name::AbstractString; kwargs....) -> Jedis.Client

Set the RediSearch Client. Clients contain an index name and a Jedis Client Struct. Kwargs are included as any Jedis client kwargs

Fields

  • index_name::String: Index name that will be created with the client.
  • client::Jedis.Client: Client object made through the Jedis package.

Examples

julia> client = Client("myIdx");

julia> client = Client("myIdx"; host="localhost", port=6379);
source
RediSearch.GeoFieldMethod
GeoField(name; kwargs...)

Creates a GeoField object.

Arguments

  • name: Name of the field.

KeyWords

  • kwargs...: Additional fields defined in the Field object.

Returns

  • GeoField::Field
source
RediSearch.NumericFieldMethod
NumericField(name; kwargs...)

Creates a NumericField object.

Arguments

  • name: Name of the field.

KeyWords

  • kwargs...: Additional fields defined in the Field object.

Returns

  • NumericField::Field
source
RediSearch.SortByFieldMethod
SortByField(field::AbstractString; asc::Bool=true)

Create a Fitler object for sorting specific fields.

Arguments

  • field::AbstractString: Field name that is being sorted

KeyWords

  • asc::Bool: Sort by ascending, default as true

Returns

  • Fitler::AbstractFilter
source
RediSearch.TagFieldMethod
TagField(name; separator=",", kwargs...)

Creates a TagField object.

Arguments

  • name: Name of the field.

KeyWords

  • separator: Separator string.
  • kwargs...: Additional fields defined in the Field object.

Returns

  • TagField::Field
source
RediSearch.TextFieldMethod
TextField(name; weight=1.0, no_stem=false, phonetic=nothing, kwargs...)

Creates a TextField.

Arguments

  • name: Name of the field.

KeyWords

  • weight: Weight of the field.
  • no_stem: Stem bool.
  • phonetic: Phonetic reference.
  • kwargs...: Additional fields defined in the Field object.

Returns

  • TextField::Field
source
RediSearch.create_indexMethod
create_index(
    fields;
    client=get_search_client(),
    no_term_offsets=false,
    no_field_flags=false,
    stopwords=nothing,
    definition=nothing,
    max_text_fields=false,
    temporary=nothing,
    no_highlight=false,
    no_term_frequencies=false,
    skip_initial_scan=false,
)
create_index(field::AbstractField; kwargs...) = create_index([field]; kwargs...)

Creates an index with the given spec. If an index already exists, this will error.

Arguments

  • fields: List of Field objects

Keywords

  • client: Search client
  • no_term_offsets: Bool for offsets.
  • no_field_flags: Bool for field flags
  • stopwords: List of stopwords. If nothing, default stopwords are used.
  • definition: Index Definition object.
  • max_text_fields: Forces RediSearch to encode indexes as if there were more than 32

text attributes.

  • temporary: Create a lightweight temporary index which will expire after the specified

period of inactivity.

  • no_highlight: Conserves storage space and memory by disabling highlighting support.
  • no_term_frequencies: If true, we avoid saving the term frequencies in the index.
  • skip_initial_scan: If true, we do not scan and index.
source
RediSearch.drop_indexMethod
drop_index(index; client=get_search_client())

Drop an index against a Client.

Arguments

  • index: Index name to be dropped

Keywords

  • client::SearchClient: RediSearch Client
source
RediSearch.get_argsMethod
get_args(q::AbstractQuery) -> Vector{Union{String,Number}}

For a query object, compile all the redis arguemnts that will be used when searching in RediSearch.

Arguments

  • q::AbstractQuery: Query object.
source
RediSearch.highlight!Method
highlight!(
    q::AbstractQuery; fields::AbstractArray=nothing, tags::AbstractArray=nothing
)

Highlighting will highlight the found term (and its variants) with a user-defined tag. 
This may be used to display the matched text in a different typeface using a markup 
language, or to otherwise make the text appear differently.

Arguments

  • q::AbstractQuery: Query object.

KeyWords

  • fields::AbstractArray: List of fields
  • tags::AbstractArray: User Tag objects.
source
RediSearch.redis_argsMethod
redis_args(field::AbstractField)

Create an array of strings to represent the RedisArgs of a Field.

Arguments

  • field::AbstractField: Field to fetch arguements for.

Returns

  • AbstractArray{String}: List of strings that represent Redis arguments.
source
RediSearch.return_field!Method
return_field!(q::AbstractQuery, field::AbstractString, as_field::AbstractString)

Map a return field to a new name

Arguments

  • q::AbstractQuery: Query object
  • field::AbstractString: Field to be mapped
  • as_field::AbstractString: Name for mapping to be made.
source
RediSearch.return_fields!Method
return_fields!(q::AbstractQuery, fields::AbstractArray)

Alter the query object to only return specific fields

Arguments

  • q::AbstractQuery: Query object
  • fields::AbstractArray: List of fields to be returned
source
RediSearch.searchMethod
search(q::AbstractQuery; client=get_search_client()) -> Result

Using a query objects, search RediSearch.

Arguments

  • q::AbstractQuery: Query object.

KeyWords

  • client: Client that will be searched.
source

Private Functions

These functions are internal to RediSearch.

RediSearch.DocumentType
Document(id::AbstractString; score=nothing, payload=nothing, kwargs...) -> Document

A RediSearch Document that is returned from a search query.

Attributes

  • id::String: Redis Key id that the document is stored in.
  • score::Union{Float64,Nothing}: Match Score for the document based on the search

criteria.

  • payload::Union{Nothing,AbstractDict}: Payload returned buy the query.
  • kwargs: Additional redis fields.
source
RediSearch.FilterType
Filter
Filter{AbstractFilter}

Filter object that can be used in RediSearch

Fields

  • args::AbstractArray: Redis args that will be used when searching
source
RediSearch.ResultType
Result(total, duration, docs)

Formatted response object from redis.

Fields

  • total::Integer: Number of results found for the
  • duration::Float64: Length of time taken to find all results.
  • docs::Vector{Document}: Documents objects that are returned from a search.
source
RediSearch.ResultsMethod
Results(res, has_content, duration; has_payload=false, with_scores=false)

Create the Result object from a Redis search response.

Arguments

  • res: Response from Redis
  • has_content: Bool flag for if there is content returned
  • duration: Time taken for query to return results

Keywords

  • has_payload::Bool: Flag for payload bring returned.
  • with_scores::Bool: Flag for scores being returned.
source
RediSearch.summarize!Method
summarize!(
    q::AbstractQuery;
    fields::Union{Nothing,AbstractArray}=nothing,
    context_len::Union{Nothing,Number}=nothing,
    num_frags::Union{Nothing,Number}=nothing,
    sep::Union{Nothing,AbstractString}=nothing,
)

Create a summary summary object to be used in the query.

Arguments

  • q::AbstractQuery: Query object

KeyWords

  • fields::Union{Nothing,AbstractArray}:Array of fields to summarize
  • context_len::Union{Nothing,Number}:Context length
  • num_frags::Union{Nothing,Number}:Number of Fragments to include
  • sep::Union{Nothing,AbstractString}:Separater string.
source