# * qualifiers: An array of qualifiers with which you can define which category you’d like to search, for example “title:hobbit” will search for hobbit in just title categories. Example: qualifiers: [:t, :titre, :title] (use it for example with multiple languages). Default is the name of the category.

# * qualifier: Convenience options if you just need a single qualifier, see above. Example: qualifiers => :title. Default is the name of the category.

# * source: Use a different source than the index uses. If you think you need that, there might be a better solution to your problem. Please post to the mailing list first with your application.rb :)

# * from: Take the data from the data category with this name. Example: You have a source Sources::CSV.new(:title, file:'some_file.csv') but you want the category to be called differently. The you use from: define_category(:similar_title, :from => :title).

#

defcategorycategory_name, options= {}

new_category =Category.new category_name.to_sym, self, options

categories << new_category

new_category =yield new_category ifblock_given?

new_category

end

alias define_category 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 #define_category.

# * range: The range (in the units of your data values) around the query point where we search for results.