GithubHelp home page GithubHelp logo

reindexer-ruby's Introduction

Gem Reindexer

Reindexer Ruby

gRPC client for work with reindexer. It is still in alpha state and there are a lot of works to do. So using in a prod environment is not recomended.

The gem also wraps the arguments of gRPC requests into the gRPC messages. So you should not care about the toons of nested initializations. Just give a common hash and the gem will do all the work.

Installation

Add this line to your application's Gemfile:

gem 'reindexer'

And then execute:

bundle

Or install it yourself as:

gem install reindexer

Usage

client = Reindexer::Client.new('grpc://reindexer:16534')
client.create_database(db_name: 'test_db')
client.open_namespace(db_name: 'test_db', storage_options: {ns_name: 'items'})
client.add_index(db_name: 'test_db', ns_name: 'items', definition: {
  name: 'id',
  json_paths: ['id'],
  index_type: 'hash',
  field_type: 'int',
  options: {
    is_pk: true,
    is_array: false,
    is_dense: false,
    is_sparse: false,
    collate_mode: 'CollateUTF8Mode',
    sort_order_labled: '',
    config: ''
  },
  expire_after: nil
})
client.modify_item([
  {db_name: 'test_db', ns_name: 'items', mode: :UPSERT, data: JSON.dump(id: 1, name: 'Name')},
  {db_name: 'test_db', ns_name: 'items', mode: :UPSERT, data: JSON.dump(id: 2, name: 'BestName')}
])
stream = client.select_sql(db_name: 'test_db', sql: 'SELECT * FROM items', output_flags: {with_rank: true})

Contributing

If you have any questions about Reindexer, please use main page of Reindexer. Feel free to report issues and contribute about Reindexer Ruby at https://github.com/numbata/reindexer-ruby.

License

The gem is available as open source under the terms of the Apache-2.0

reindexer-ruby's People

Contributors

depfu[bot] avatar numbata avatar

Stargazers

 avatar

Watchers

 avatar

reindexer-ruby's Issues

ActiveRecord Database adapter

In the world full of ๐Ÿฆ„ and ๐Ÿฆ‹ it would be nice to easily do something like this:

# database.yml

reindexer_production:
  adapter: reindexer_grps
  host: reindexer
  database: animals_app_production
  port: 16536
  migrations_paths: db/reindexer_migrations
# Migration
class CreateDogsIndex < ActiveRecord::Migration[7.0]
  def change
    create_table :dogs_index do |t|
      t.string :name
      t.integer :age
  
      t.timestamps
    end
  end
end

# Models
class ReindexerRecord < ActiveRecord::Base
  self.abstract_class = true

  establish_connection :reindexer_production 
end

class DogsIndex < ReindexerRecord
  self.table_name = :dogs_index # namespace in terms of Reindexer
end

# Somewhere in the app
DogsIndex.create!(name: "Laika", age: 2)
DogsIndex.first_by(name: "Laika")

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.