Caoutsearch \ˈkawt͡ˈsɝtʃ\
!! Gem under development before public release !!
Caoutsearch is a new Elasticsearch integration for Ruby and/or Rails.
It provides a simple but powerful DSL to perform complex indexing and searching, while securely exposing search criteria to a public and chainable API, without overwhelming your models.
Caoutsearch only supports Elasticsearch 8.x right now.
It is used in production in a robust application, updated and maintained for several years at Solutions & Territoire.
Caoutsearch was inspired by awesome gems such as elasticsearch-rails or search_flip.
Depending on your search scenarios, they may better suite your needs.
Visit our offical documentation to understand how to use Caoutsearch.
Add the gem in your Gemfile:
bundle add caoutsearch
Caoutsearch let you create Index
and Search
classes to manipulate your data :
class ArticleIndex < Caoutsearch::Index::Base
property :title
property :published_on
property :tags
def tags
records.tags.public.map(&:to_s)
end
end
ArticleIndex.reindex(:tags)
class ArticleSearch < Caoutsearch::Search::Base
filter :title, as: :match
filter :published_on, as: :date
filter :tags
has_aggregation :popular_tags, {
filter: { term: { published: true } },
aggs: {
published: {
terms: { field: :tags, size: 10 }
}
}
}
end
ArticleSearch.search(published_on: [["now-1y", nil]]).aggregate(:popular_tags)
- Don't hesitate to submit your feature/idea/fix in issues
- Fork the repository
- Create your feature branch
- Ensure RSpec & Rubocop are passing
- Create a pull request
bundle exec rspec
bundle exec rubocop
bundle exec standardrb
To run RSpec against various version of Rails dependencies:
bundle exec appraisal install
bundle exec appraisal rspec
All of them can be run with:
bundle exec rake
Please see LICENSE for further details.
Contributors: ./graphs/contributors