Skip to content

r-icarus/active_lucene

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ABOUT:

ActiveLucene is an ActiveRecord/ActiveModel’s like interface to Apache Lucene, with support for dynamic attributes, pagination, highlighting and Lucene’s query syntax.

ActiveLucene was extracted from Lunr:

http://github.com/dcrec1/lunr

ActiveLucene works with JRuby like this:

class Advertise < ActiveLucene::Document
end

Advertise.create! :param1 => 'value 1', :param2 => 'value 2'

Advertise.find :all
Advertise.find "5"

Advertise.search "value*"
Advertise.search "param2:'value 2' AND param3:lorem"
Advertise.search "param2:value OR param3:lorem"

Advertise.search :param1 => 'value 1', :param2 => 'value'

Advertise.search(:param1 => 'va?ue').first.highlight

Advertise.search(:param1 => 'va?ue').total_pages

Advertise#search accepts as a parameter any query supported by Lucene. For more information:

http://lucene.apache.org/java/2_3_2/queryparsersyntax.html

Note that you don’t need to specify attributes, they are dynamic!

The pagination is supposed to be compatible with will_paginate:

http://github.com/mislav/will_paginate

For more examples, please refer to the specs.

To use it in rails
config/initializer/active_lucene.rb


  ActiveLucene::Index::PATH = "#{Rails.root}/tmp/db/lucene/#{Rails.env}"

LICENSE:

(The MIT License)

Copyright © 2010

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
‘Software’), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

ActiveRecord/ActiveModel's like interface for Lucene

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%