struct Redis::FullText(Runnable)

Overview

Redis::FullText wraps a Redis::Client or Redis::Cluster to execute commands against a fulltext search index located on a given server.

redis = Redis::Client.new
redis.ft.create <<-INDEX
  people-index ON HASH
    PREFIX 1 person:
  SCHEMA
    name TEXT NOSTEM SORTABLE
    email TEXT NOSTEM SORTABLE
    location GEO
INDEX

If your Redis server is running in Cluster mode, you can require "redis/cluster/search" to send read-only FullText commands to shard replicas.

EXPERIMENTAL RediSearch support is still under development. Some APIs may change while details are discovered.

Defined in:

search.cr

Instance Method Summary

Instance Method Detail

def create(string : String) #

Create a search index using the syntax specified in the RediSearch FT.CREATE docs.

redis = Redis::Client.new
redis.ft.create <<-INDEX
  people-index ON HASH
    PREFIX 1 person:
  SCHEMA
    name TEXT NOSTEM SORTABLE
    email TEXT NOSTEM SORTABLE
    location GEO
INDEX

NOTE This method returns immediately, before the index is complete. You can run searches against an incomplete index, but you will also have incomplete results. To find how far along the index is, you can use the #info method.

TODO Add a method that generates the string passed into this overload.


[View source]
def drop(index : String, keepdocs = false) #

Drop the specified index.


[View source]
def dropindex(key : String, keepdocs = false) #

Drop the specified index.


[View source]
def info(index : String) #

Get information about the search index contained in index. For more details, see the FT.INFO documentation.


[View source]
def profile(index : String, query : String) #

Profile the given search. For further details, see the FT.PROFILE documentation.


[View source]
def search(index : String, query : String, nocontent = false, verbatim = false, nostopwords = false, withscores = false, withpayloads = false, withsortkeys = false, filter : Array(Filter) | Nil = nil, geofilter : GeoFilter | Nil = nil, inkeys : Array(String) | Nil = nil, infields : Array(String) | Nil = nil, return return_value : Array(String) | Nil = nil, summarize : Summarize | Nil = nil, highlight : Highlight | Nil = nil, slop : Int | Nil = nil, timeout : Time::Span | Nil = nil, inorder : Bool | Nil = nil, language : String | Nil = nil, expander : String | Nil = nil, scorer : String | Nil = nil, explainscore : Bool | Nil = nil, payload : String | Bytes | Nil = nil, sortby : SortBy | Nil = nil, limit : Tuple(Int, Int) | Nil = nil, params : NamedTuple | Hash(String, String) | Nil = nil, dialect : Int | Nil = nil) #

Run the specified query against index. Customize the search with various other arguments. For details about what each one does and the return value, see the FT.SEARCH documentation.

result = redis.ft.search "people-index", "@name:Jamie",
  return: %w[name email],
  sortby: Redis::FullText::SortBy.new("name", :asc)

[View source]
def tagvals(index : String, field : String) #

[View source]