lib/thinking_sphinx/search_methods.rb in warp-thinking-sphinx-1.2.12 vs lib/thinking_sphinx/search_methods.rb in warp-thinking-sphinx-1.3.10
- old
+ new
@@ -153,11 +153,11 @@
#
# This would become "*elbourn* -*ustrali*". The :star option only adds the
# asterisks. You need to make the config/sphinx.yml changes yourself.
#
# By default, the tokens are assumed to match the regular expression
- # /\w+/u. If you've modified the charset_table, pass another regular
+ # /\w\+/u\+. If you've modified the charset_table, pass another regular
# expression, e.g.
#
# User.search("oo@bar.c", :star => /[\w@.]+/u)
#
# to search for "*oo@bar.c*" and not "*oo*@*bar*.*c*".
@@ -311,16 +311,34 @@
# end
#
# Once you've got your results set, you can access the distances as
# follows:
#
- # @results.each_with_geodist do |result, distance|
- # # ...
- # end
+ # @results.each_with_geodist do |result, distance|
+ # # ...
+ # end
#
# The distance value is returned as a float, representing the distance in
# metres.
#
+ # == Filtering by custom attributes
+ #
+ # Do note that this applies only to sphinx 0.9.9
+ #
+ # Should you find yourself in desperate need of a filter that involves
+ # selecting either one of multiple conditions, one solution could be
+ # provided by the :sphinx_select option within the search.
+ # This handles which fields are selected by sphinx from its store.
+ #
+ # The default value is "*", and you can add custom fields using syntax
+ # similar to sql:
+ #
+ # Flower.search "foo",
+ # :sphinx_select => "*, petals < 1 or color = 2 as grass"
+ #
+ # This will add the 'grass' attribute, which will now be usable in your
+ # filters.
+ #
# == Handling a Stale Index
#
# Especially if you don't use delta indexing, you risk having records in
# the Sphinx index that are no longer in the database. By default, those
# will simply come back as nils: