Call For Papers for RedisConf18 is Open Until December 31!   Submit here

Redise Modules

RediSearch : The Full Text Search Module

Real time, highly available and scalable full text search

Achieve full text search with 5x improvement in throughput and latency compared to search engines like ElasticSearch and Solr.
Gain advanced features such as scoring, filtering, query expansion using stemming, automatic suggestions and many more, delivered simply with efficient use of resources.

Benefit from the enterprise grade scale and high availability of Redise technology, that underpins these enterprise modules.

How it works

redisearch implements a search engine on top of Redis, but unlike other Redis search libraries, it does not use internal data structures like sorted sets.
Inverted indexes are stored on top of Redis strings using the modules DMA method.
This allows much faster performance, significantly less memory consumption, and more advanced features like exact phrase matching, that are not possible with traditional Redis search approaches.
Benchmark

Download Benchmark

Quick Guide

  1. Creating an index with fields and weights:
    127.0.0.1:6379> FT.CREATE myIdx title 5.0 body 1.0 url 1.0 OK
  2. Adding documents to the index:
    127.0.0.1:6379> FT.ADD doc1 1.0 title “hello world” body “lorem ipsum” url “http://redis.io” OK
  3. Searching the index:
    127.0.0.1:6379> FT.SEARCH “hello world” LIMIT 0 10 1) (integer) 1 2) “doc1” 3) 1) “title” 2) “hello world” 3) “body” 4) “lorem ipsum” 5) “url” 6) “http://redis.io”

Commands

  • FT.ADD index_name doc_id score [NOSAVE] FIELDS field1 content1 field2 content2 ...

    Add a documet to the index.

    Parameters:

    • index: The Fulltext index name. The index must be first created with FT.CREATE
    • docId: The document’s id that will be returned from searches. Note that the same docId cannot be added twice to the same index
    • score: The document’s rank based on the user’s ranking. This must be between 0.0 and 1.0. If you don’t have a score just set it to 1
    • NOSAVE: If set to true, we will not save the actual document in the index and only index it.
    • FIELDS: Following the FIELDS specifier, we are looking for pairs of to be indexed.
      Each field will be scored based on the index spec given in FT.CREATE.
      Passing fields that are not in the index spec will make them be stored as part of the document,
      or ignored if NOSAVE is set

    Return Value

    Simple String Reply: OK if the the document was added to the index, error otherwise.

    Examples

    redis> FT.ADD docs doc1 1.0 FIELDS title “war and peace” body “Well, Prince, so Genoa and Lucca are now…”
    OK

  • FT.CREATE index_name field1 weight1 field2 weight2 ...

    Creates an index with the given spec. The index name will be used in all the key names
    so keep it short!

    Parameters:

    • index: the index name to create. If it exists the old spec will be overwritten
    • field / weight pairs: pairs of field name and relative weight in scoring.
      The weight is a double, but does not need to be normalized.

    Return Value

    Simple String Reply: OK if the index was created, an error otherwise.

    Examples

    redis> FT.CREATE docs title 2.0 body 1.0 url 1.5
    OK

  • FT.SEARCH index query [NOCONTENT] [LIMIT offset num]

    Search the index with a textual query, returning either documents or just ids.

    Parameters:

    • index: The Fulltext index name. The index must be first created with FT.CREATE
    • query: the text query to search. If it’s more than a single word, put it in quotes.
      Basic syntax like quotes for exact matching is supported.
    • NOCONTENT: If it appears after the query, we only return the document ids and not
      the content. This is useful if redisearch is only an index on an external document collection
    • LIMIT fist num: If the parameters appear after the query, we limit the results to
      the offset and number of results given. The default is 0 10

    Return Value

    Array reply: A list where the first element is the number of total results, regardless of paging, followed by each document’s id, and a nested list of the document’s fields.

    If NOCONTENT is specified, the list just contains the total number of results, and document ids.

    Examples

    redis> FT.SEARCH idx “hello world” LIMIT 0 1
    1) (integer) 5
    2) “Hello_Cruel_World”
    3) 1) “body”
    2) “Hello Cruel World may refer to:”
    3) “url”
    4) “https://en.wikipedia.org/wiki/Hello_Cruel_World”
    5) “title”
    6) “Hello Cruel World”
    redis> FT.SEARCH idx{0} “hello world” LIMIT 0 1 NOCONTENT
    1) (integer) 5
    2) “Hello_Cruel_World”

Request This Module