No release in over 3 years
Drop-in ActiveRecord concern that keeps KakugoSearch indexes in sync with your models via save/destroy callbacks, plus a search class method.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.0
~> 3.0

Runtime

>= 6.0
 Project Readme

kakugosearch-rails

Rails integration for KakugoSearch — a lightweight, AI-enhanced full-text search engine written in Rust.

Installation

Add to your Gemfile:

gem "kakugosearch-rails"

Then run:

bundle install

Configuration

# config/initializers/kakugosearch.rb
KakugoSearch.configure do |config|
  config.url     = "http://localhost:7700"          # KakugoSearch server URL
  config.api_key = ENV["KAKUGOSEARCH_AI_API_KEY"]   # optional, for AI reranking
end

Usage

Include KakugoSearch::Searchable in any ActiveRecord model and declare which fields to index:

class Article < ApplicationRecord
  include KakugoSearch::Searchable

  kakugosearch_index(
    index:  "articles",          # index name (defaults to table_name)
    fields: {
      title: :title,             # KakugoSearch field => AR attribute/method
      body:  :content,
      url:   :permalink,
    }
  )
end

Records are automatically indexed on save and removed from the index on destroy.

Searching

# Basic search
results = Article.kakugosearch("rust programming")

# With options
results = Article.kakugosearch("machine learning",
  limit:     10,
  ai:        true,    # enable AI reranking
  ai_weight: 0.5      # blend of BM25 vs AI (0.0–1.0)
)

Returns ActiveRecord objects in ranked order.

Behaviour Notes

  • Synchronous — indexing happens inline with save/destroy. Wrap in after_commit if you need post-transaction indexing.
  • Errors on indexing are logged, not raised — a failed HTTP call to KakugoSearch will not break your model save.
  • Errors on search do raise — a KakugoSearch::Error is raised so callers can handle it.

Development

bundle install
bundle exec rspec

License

MIT