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:
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.serach(:param1 => 'va?ue').first.highlight Advertise.serach(:param1 => 'va?ue').total_pages
Advertise#search accepts as a parameter any query supported by Lucene. For more information:
Note that you don’t need to specify attributes, they are dynamic!
The pagination is supposed to be compatible with will_paginate:
For more examples, please refer to the specs.
(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.