Giter Site home page Giter Site logo

sunspot_mongoid2's Introduction

sunspot_mongoid 2

A Sunspot wrapper for Mongoid that just works.

Gemfile

gem 'sunspot_mongoid2'
bundle install

For Rails 3.x

Configure your gem

Create config/initializers/sunspot_mongoid.rb:

Sunspot.session = Sunspot::Rails.build_session
ActionController::Base.module_eval { include(Sunspot::Rails::RequestLifecycle) }

Don't forget to restart your rack server (or pow.cx)

as plugin (only if really needed):

add gems to Gemfile as following,

gem 'sunspot_mongoid2'
gem 'sunspot_rails'

and install sunspot_mongoid as rails plugin,

rails plugin install https://github.com/hlegius/sunspot_mongoid2.git

A Simple Example

class Post
  include Mongoid::Document
  include Sunspot::Mongoid2

  searchable do
    text :title
  end

  field :title
end

class SomeController < ActionController::Base
  def index
    search = Sunspot.search(Post) do
      fulltext params[:q]
    end
    
    @results = search.results
    @total_lines = search.total
  end
end

# http://yourapplication.dev/search?q=foobarbaz

Links

Copyright (and left)

Copyright (c) 2010 jugyo. See LICENSE for details.

A lot of other contributions were made before I did.

sunspot_mongoid2's People

Contributors

aq1018 avatar benoberkfell avatar mattbeedle avatar perezd avatar iamveen avatar ryanbond avatar

Watchers

Michael Toppa avatar James Cloos 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.