Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mindex

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mindex

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Gem Version

Mindex

This gem provides functionality to build elasticsearch indices.

Installation

Add the following line to your Gemfile:

gem 'mindex'

And then execute:

$ bundle

Example

Index declaration

module Index
  class Event
    include Mindex::Index

    def self.scroll(options = {})
      query = Event
      query = query.where('"updated_at" >= ?', options[:started_at]) if options[:started_at]
      query.find_in_batches do |events|
        yield index_data(events)
      end
    end

    def self.fetch(ids)
      Event.where(id: ids).map do |event|
        index_data(event)
      end
    end

    private

    def index_data(events)
      [events].flatten.map do |event|
        {
          id:         event.id,
          name:       event.name,
          updated_at: event.updated_at,
          created_at: event.created_at
        }
      end
    end
  end
end

Usage

recreate index

Event.recreate_index

reindex all items

Event.reindex

index specific items

Event.reindex_items([2903, 2016])

drop items

Event.drop_items([29, 3])

get item from elasticsearch

Event.es.get(index: Event.index_alias, id: 2903)

Contributing

Please create an issue or merge request

FAQs

Package last updated on 01 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc