Giter Club home page Giter Club logo

redisearch-rb's Introduction

Gem Version travis-ci

redisearch-rb

A simple Ruby client for RediSearch module http://redisearch.io/

Installation

First of all, you need to install RediSearch, if you haven't yet:

  1. Install Redis 4.0.1 or highger https://github.com/antirez/redis/releases/tag/4.0.1
  2. Install RediSearch 1.2.0 or higher http://redisearch.io/Quick_Start/
  3. Edit your redis.conf file and add a loadmodule directive to load the RediSearch module built in the step 2.

To install this gem, add this line to your application's Gemfile:

gem 'redisearch-rb'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install redisearch-rb

In order to run the tests, it's necessary to set some env variables (see .env.example):

  • REDIS_SERVER_PATH, the path to the redis-server executable

  • REDIS_MODULE_PATH, the path to the redisearch.so module

  • REDIS_CONF_PATH, the two previous parameters can be configured using a redis conf file. In case REDIS_CONF_PATH is given, the values of the env vars REDIS_SERVER_PATH and REDIS_MODULE_PATH are ignored.

Usage

require 'redisearch-rb'

redis = Redis.new(url: REDIS_URL)
redisearch_client = RediSearch.new('test_idx', redis)

schema = ['title', 'TEXT', 'WEIGHT', '2.0',
          'director', 'TEXT', 'WEIGHT', '1.0',
          'year', 'NUMERIC', 'SORTABLE']

redisearch_client.create_index(schema, { nooffsets: true })
# => "OK"

docs = [['id_1', ['title', 'Lost in translation', 'director', 'Sofia Coppola', 'year', '2004']],
        ['id_2', ['title', 'Ex Machina', 'director', 'Alex Garland', 'year', '2014']]]
redisearch_client.add_docs(docs, { replace: true })
# => ["OK", "OK"]

# See query syntax here: http://redisearch.io/Query_Syntax/
redisearch_client.search('lost|machina', { withscores: true, limit: ['0', '2'] })
# => [{"title"=>"Ex Machina", "director"=>"Alex Garland", "year"=>"2014", "score"=>"2", "id"=>"id_2"},
#   {"title"=>"Lost in translation", "director"=>"Sofia Coppola", "year"=>"2004", "score"=>"1", "id"=>"id_1"}]

redisearch_client.search('@year:[2003 2017]', { sortby: ['year', 'asc'], limit: ['0', '1'] })
# => [{"title"=>"Lost in translation", "director"=>"Sofia Coppola", "year"=>"2004", "id"=>"id_1"}]

redisearch_client.search('@year:[2003 2017]', { sortby: ['year', 'asc'], limit: ['1', '1'] })
# => [{"title"=>"Ex Machina", "director"=>"Alex Garland", "year"=>"2014", "score"=>"2", "id"=>"id_2"}

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/vruizext/redisearch-rb.

License

The gem is available as open source under the terms of the MIT License.

redisearch-rb's People

Contributors

vruizext avatar gkorland avatar matthiaswinkelmann avatar

Stargazers

Sebastián Orellana avatar Tomoya Chiba avatar Josh Kaufman avatar Igor Zubkov avatar Marco Roth avatar Albert Salim avatar Maxim Madzhuga avatar  avatar Davide Santangelo avatar Jonian Guveli avatar Vladimir Glusic avatar Zachary Powell avatar Rudy Zidan avatar Luca Ongaro avatar Rami Bitar avatar Noah Everett avatar Rafał W avatar  avatar Brent Mulligan avatar Christoph Grabo avatar Christian Bankester avatar Aung Kyaw Phyo avatar Vincent Xie avatar  avatar Peter Alcock avatar Wesley Conde avatar Montana Flynn avatar wyben lam avatar Stan Bright avatar Samuel Martini avatar Ihor Shevkun avatar Anatoly Chernov avatar Avishek Jana avatar  avatar Kris Chambers avatar Byungjik Roh avatar steve avatar Jon Collier avatar Dvir Volk avatar

Watchers

Wesley Conde avatar  avatar  avatar

redisearch-rb's Issues

Lower Ruby dependency if possible

Is there a reason to have a dependency on version 2.4.1 of Ruby ? It prevents us to use this gem in a Logstash plugin (or any other JRuby environment).

Need detailed documentation support

The current document of redisearch-rb gem shows the usage of, or mentions, the following methods:

  1. client initialization
  2. create_index
  3. add_docs
  4. search

However, the source code supports the following methods:

  1. client initialization
  2. create_index
  3. drop_index
  4. add_doc
  5. search
  6. get_by_id
  7. info

Request creating a more detailed documentation for all the methods supported so that it becomes easier to use them.

Gem should support deleting documents from index

It looks like the redisearch-rb gem lacks support for deleting documents from a created index. Specifically, support for FT.DEL command of RediSearch.

Request implementing this feature in an expedited manner so that the gem, RediSearch, and Redis can be used with a Rails server.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.