Sha256: f37aea7ba39fadc777ad25a7a27ecd208ea3ef8ea835b466ef5e1dbd01fd0d72

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

Lunar
=====

A minimalistic search index implemented using Redis, taking advantage of its 
powerful `sorted sets` and the ability to do set intersection and union.

Results are sorted by their word score, which is stored as the score in the
Redis sorted set.

Examples
--------

    class Item < Ohm::Model
      attribute :name
      attribute :description
      
    protected
      def write
        super
        index
      end

      def index
        Lunar::Index.create 'Item' do |i|
          i.key  id
          i.attr :name, name
          i.attr :description, description
        end
        
        # You can also do this, no problem
        Lunar::Index.create Item do |i|
          i.key  id
          i.attr :name, name
          i.attr :description, description
        end

        # Or to avoid name ties...
        Lunar::Index.create self.class do |i|
          i.key  id
          i.attr :name, name
          i.attr :description, description
        end
      end
    end

    # Searching...
    # You can just straight out search keywords
    Lunar.search(Item, "iphone")

    # Or opt to filter by field
    Lunar.search(Item, :name => "iphone", :description => "mobile")

    # Or using the pagination gem with this:
    @items = Lunar.search(Item, "iphone")
    paginate @items, :per_page => 10, :page => 1

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lunar-0.2.3 README.md
lunar-0.2.2 README.md
lunar-0.2.1 README.md
lunar-0.2.0 README.md