Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/undr/fuzzzy
The fuzzy search with redis-stored indexes
https://github.com/undr/fuzzzy
Last synced: about 1 month ago
JSON representation
The fuzzy search with redis-stored indexes
- Host: GitHub
- URL: https://github.com/undr/fuzzzy
- Owner: undr
- Created: 2012-03-23T03:30:15.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-07-19T16:43:17.000Z (over 12 years ago)
- Last Synced: 2024-10-13T16:52:30.148Z (2 months ago)
- Language: Ruby
- Homepage:
- Size: 294 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fuzzzy
The fuzzy search with redis-stored indexes.
[![Build Status](https://secure.travis-ci.org/undr/fuzzzy.png?branch=master)](http://travis-ci.org/undr/fuzzzy)
## Install and configuration
Add to Gemfile:
gem 'fuzzzy'
and run `bundle install`
Configuration is very simple:
Fuzzzy.configure do |config|
config.logger = Logger.new($stdout)
config.redis = Redis.new(
:host => 'localhost',
:port => 6379,
:database => 0
)
config.stopwords = %w{the stopwords list}
endPut this code in initializers folder if you use rails or at the beginning of the application otherwise.
## Usage
There are several ways to use:
- **As standalone module.**
- **As MongoId module.**
- **As HTTP server.**
### As standalone module
class CitySearch
include Fuzzzy::Index
def search context
_searcher.search(context)
end
def create_index context
_indexer.create_index(context)
end
def delete_index context
_indexer.delete_index(context)
end
end
s = CitySearch.new
s.create_index(
:method => :ngram,
:index_name => 'city',
:dictionary_string => 'Moscow',
:id => '1'
)
s.create_index(
:method => :ngram,
:index_name => 'city',
:dictionary_string => 'Rom',
:id => '2'
)
result = s.search({
:method => :ngram,
:index_name => 'city',
:query => 'Moskow',
:distance => 1
})
puts result # 1### As MongoId module
class City
include Mongoid::Document
include Fuzzzy::Mongoid::Index
field :name, :type => String
define_fuzzzy_index :name, :method => :ngram
end
City.create(:name => 'Moscow')
City.create(:name => 'Rom')
pp City.search(:query => 'Moskow', :distance => 1)### As HTTP server