Code Monkey home page Code Monkey logo

sonic-ruby's Introduction

sonic-ruby

Gem Version Build Status Maintainability

A Ruby client for Sonic search backend.

Installation

Add following line to your Gemfile:

gem 'sonic-ruby'

And then execute:

$ bundle

Or install it system-wide:

$ gem install sonic-ruby

Usage

Start with creating new client:

client = Sonic::Client.new('localhost', 1491, 'SecretPassword')

Now you can use #channel method in order to connect to specific channels:

control = client.channel(:control)
ingest = client.channel(:ingest)
search = client.channel(:search)

Learn more about Sonic Channels.

Indexing

# Init `ingest` channel
ingest = client.channel(:ingest)

# Add data to index
ingest.push('users', 'all', 1, 'Alexander Tipugin')
# => true

# Remove data from index
ingest.pop('users', 'all', 1, 'Alexander Tipugin')
# => 2

# Count collection/bucket/object items
ingest.count('users', 'all', 1)
# => 1

# Flush entire collection
ingest.flushc('users')
# => 1

# Flush entire bucket inside collection
ingest.flushb('users', 'all')
# => 1

# Flush specific object inside bucket
ingest.flusho('users', 'all', 1)
# => 2

Searching

# Init `search` channel
search = client.channel(:search)

# Find indexed object by term
search.query('users', 'all', 'tipugin')
# => 1

# Auto-complete word
search.suggest('users', 'all', 'alex')
# => alexander

TODO

  • Take into account maximum buffer size.
  • Consider using connection pool.
  • Return more meaningful responses from commands (i.e. bool true instead of string OK, int 1 instead of string RESULT 1 etc).

sonic-ruby's People

Contributors

atipugin avatar zealot128 avatar

Watchers

 avatar

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.