RediSearch Documentation
Public Functions
These functions are exported by RediSearch.
RediSearch.Field
— TypeField::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
RediSearch.IndexDefinition
— TypeIndexDefinition(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.
RediSearch.IndexDefinition
— MethodIndexDefinition(;
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.
RediSearch.Query
— TypeQuery(
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::Bool
verbatim setting forwith_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
RediSearch.SearchClient
— TypeClient(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);
RediSearch.GeoField
— MethodGeoField(name; kwargs...)
Creates a GeoField object.
Arguments
name
: Name of the field.
KeyWords
kwargs...
: Additional fields defined in theField
object.
Returns
GeoField::Field
RediSearch.NumericField
— MethodNumericField(name; kwargs...)
Creates a NumericField object.
Arguments
name
: Name of the field.
KeyWords
kwargs...
: Additional fields defined in theField
object.
Returns
NumericField::Field
RediSearch.SortByField
— MethodSortByField(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 astrue
Returns
Fitler::AbstractFilter
RediSearch.TagField
— MethodTagField(name; separator=",", kwargs...)
Creates a TagField object.
Arguments
name
: Name of the field.
KeyWords
separator
: Separator string.kwargs...
: Additional fields defined in theField
object.
Returns
TagField::Field
RediSearch.TextField
— MethodTextField(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 theField
object.
Returns
TextField::Field
RediSearch._mk_query_args
— Method_mk_query_args(query; client=get_search_client())
From a query object, generate the search arguments.
RediSearch.create_index
— Methodcreate_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 clientno_term_offsets
: Bool for offsets.no_field_flags
: Bool for field flagsstopwords
: 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.
RediSearch.drop_index
— Methoddrop_index(index; client=get_search_client())
Drop an index against a Client.
Arguments
index
: Index name to be dropped
Keywords
client::SearchClient
: RediSearch Client
RediSearch.get_args
— Methodget_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.
RediSearch.get_search_client
— MethodReturn the client object for RediSearch
RediSearch.highlight!
— Methodhighlight!(
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 fieldstags::AbstractArray
: User Tag objects.
RediSearch.limit_ids!
— Methodlimit_ids!(q::AbstractQuery, ids::AbstractArray)
Alter a query to only return specific IDs
RediSearch.redis_args
— Methodredis_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.
RediSearch.return_field!
— Methodreturn_field!(q::AbstractQuery, field::AbstractString, as_field::AbstractString)
Map a return field to a new name
Arguments
q::AbstractQuery
: Query objectfield::AbstractString
: Field to be mappedas_field::AbstractString
: Name for mapping to be made.
RediSearch.return_fields!
— Methodreturn_fields!(q::AbstractQuery, fields::AbstractArray)
Alter the query object to only return specific fields
Arguments
q::AbstractQuery
: Query objectfields::AbstractArray
: List of fields to be returned
RediSearch.search
— Methodsearch(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.
Private Functions
These functions are internal to RediSearch.
RediSearch.SEARCHCLIENT
— ConstantGlobal client of RediSearch. Used to reference the base client for RediSearch made
through `Client()`.
RediSearch.Document
— TypeDocument(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.
RediSearch.Filter
— TypeFilter
Filter{AbstractFilter}
Filter object that can be used in RediSearch
Fields
args::AbstractArray
: Redis args that will be used when searching
RediSearch.Result
— TypeResult(total, duration, docs)
Formatted response object from redis.
Fields
total::Integer
: Number of results found for theduration::Float64
: Length of time taken to find all results.docs::Vector{Document}
: Documents objects that are returned from a search.
RediSearch.Results
— MethodResults(res, has_content, duration; has_payload=false, with_scores=false)
Create the Result object from a Redis search response.
Arguments
res
: Response from Redishas_content
: Bool flag for if there is content returnedduration
: Time taken for query to return results
Keywords
has_payload::Bool
: Flag for payload bring returned.with_scores::Bool
: Flag for scores being returned.
RediSearch.isa_list
— MethodChecks if l
is a typle, list or vector type
RediSearch.summarize!
— Methodsummarize!(
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 summarizecontext_len::Union{Nothing,Number}
:Context lengthnum_frags::Union{Nothing,Number}
:Number of Fragments to includesep::Union{Nothing,AbstractString}
:Separater string.