picky
https://github.com/floere/picky
HTML
Picky is an easy to use and fast Ruby semantic search engine that helps your users find what they are looking for.
Picky::Index#ranged_category
Make this category range searchable with a fixed range. If you need other
ranges, define another category with a different range value.
Example:
You have data values inside 1..100, and you want to have Picky return
not only the results for 47 if you search for 47, but also results for
45, 46, or 47.2, 48.9, in a range of 2 around 47, so (45..49).
Then you use:
ranged_category :values_inside_1_100, 2
Optionally, you give it a precision value to reduce the error margin
around 47 (Picky is a bit liberal).
Index.new :range do
ranged_category :values_inside_1_100, 2, precision: 5
end
This will force Picky to maximally be wrong 5% of the given range value
(5% of 2 = 0.1) instead of the default 20% (20% of 2 = 0.4).
We suggest not to use much more than 5 as a higher precision is more
performance intensive for less and less precision gain.
== Protip 1
Create two ranged categories to make an area search:
Index.new :area do
ranged_category :x, 1
ranged_category :y, 1
end
Search for it using for example:
x:133, y:120
This will search this square area (* = 133, 120: The "search" point entered):
132 134
| |
--|---------|-- 121
| |
| * |
| |
--|---------|-- 119
| |
Note: The area does not need to be square, but can be rectangular.
== Protip 2
Create three ranged categories to make a volume search.
Or go crazy and use 4 ranged categories for a space/time search! ;)
=== Parameters
* category_name: The category_name as used in #category.
* range: The range (in the units of your data values) around the query point where we search for results.
-----|<- range ->*------------|-----
=== Options
* precision: Default is 1 (20% error margin, very fast), up to 5 (5% error margin, slower) makes sense.
* anchor: Where to anchor the grid.
* ... all options of #category.Edit
git clone [email protected]:floere/picky.git
cd picky
open server/lib/picky/index.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Picky--Index-ranged_category-for-pr
# Commit to gitgit add server/lib/picky/index.rbgit commit -m "better docs for Picky::Index#ranged_category"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Picky--Index-ranged_category-for-pr
hub pull-request
# Celebrate!