Hi Mickaël
I'm pretty sure I've seen this before, and it's a limitation in Sphinx
itself - it doesn't like excluding terms if no other terms are
provided (your third example).
Also, to make life more difficult, Sphinx doesn't support negation (!)
within brackets - ie, your second example:
> Negation (ie. operator NOT) is only allowed on top level and not
> within brackets (ie. groups). This isn't going to change, because
> supporting nested negations would make phrase ranking implementation
> way too complicated.
Not quite sure of the best way around this... you could add in a
manual field, a word that's in every record, and always search for at
least that:
indexes "'sphinxisbuggy'", :as => :catch_all
# ...
ThinkingSphinx.search "sphinxisbuggy", :conditions => {:last_name
=> "!ALLAIN"}
But it's definitely not a clean way of doing things.
--
Pat
On 24/02/2009, at 7:19 AM, Mickaël wrote:
>
> Hi folks !
>
> Currently i'm trying to solve a problem. With conditions to exclude
> something, TS return 0 row.
>
> Let's me show you my situation :
>
> -------------------------------------------------------
>
> My UserProfile Model
>
> define index do
>
> indexes :last_name, :sortable => true, :facet => true
> indexes :first_name, :sortable => true, :facet => true
>
> set_property :enable_star => 1
> set_property :min_prefix_len => 1
> end
>
> -------------------------------------------------------
>
> Data in my database
>
> first_name / last_name
>
> ALLAINooooo Pierre
> Zebulon Mickaël
> ALLAIN Plopinou
> ALLAIN Pierre
> Zabbuli zezeze
> Zebulon Elodie
> Zebulon Blanchard
> Zabbuli Pierrot
> Zebruska Pierre
> Ungant Pierre
>
> -------------------------------------------------------
>
> My Searches controller
>
> Different Way.
>
> First : Search with OR Include on last_name (done)
> ------------------------------------
>
> @searches = ThinkingSphinx::Search.search(session[:query], :per_page
> => self.per_page, :classes => [UserProfile], :match_mode
> => :boolean, :conditions => {:last_name => '(ALLAIN | Zebulon)'})
>
> On Log we will see
> Sphinx: @last_name (ALLAIN | Zebulon)
>
> And the result is
>
> Plopinou ALLAIN / Pierre ALLAIN / Mickaël Zebulon / Elodie Zebulon /
> Blanchard Zebulon
>
> No problem.
>
>
> Second : Search with Exclude on last_name (Wrong..)
> ------------------------------------------
>
> searches = ThinkingSphinx::Search.search(session[:query], :per_page =>
> self.per_page, :classes => [UserProfile], :match_mode
> => :boolean, :conditions => {:last_name => '(!Zebulon)'})
>
> On log we will see
> Sphinx: @last_name (!ALLAIN)
>
> And the result is...NOTHING, but no exception
>
> --- --- --- --- --- --- --- --- ---
>
> If I try another exclude pattern
>
> searches = ThinkingSphinx::Search.search(session[:query], :per_page =>
> self.per_page, :classes => [UserProfile], :match_mode
> => :boolean, :conditions => {:last_name => '!Zebulon'})
>
> On log we will see
> Sphinx: @last_name !ALLAIN
>
> But it result an exception like that :
>
> Riddle::ResponseError (No response from searchd (status: ,
> version: )):
> /vendor/plugins/thinking-sphinx/lib/../vendor/riddle/lib/riddle/
> client.rb:466:in `request'
> /vendor/plugins/thinking-sphinx/lib/../vendor/riddle/lib/riddle/
> client.rb:180:in `run'
> /vendor/plugins/thinking-sphinx/lib/../vendor/riddle/lib/riddle/
> client.rb:287:in `query'
> /vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:
> 396:in `search_results'
> /vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:
> 278:in `search'
> /vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:
> 302:in `call'
> /vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:
> 302:in `retry_search_on_stale_index'
> /vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb:
> 277:in `search'
> /app/controllers/searches_controller.rb:190:in `addfilter'
> /opt/ree/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
> action_controller/base.rb:1253:in `send'
> /opt/ree/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
> action_controller/base.rb:1253:in `perform_action_without_filters'
> /opt/ree/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
> action_controller/filters.rb:617:in `call_filters'
> /opt/ree/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
> action_controller/filters.rb:610:in `perform_action_without_benchmark'
> /opt/ree/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
> action_controller/benchmarking.rb:68:in
> `perform_action_without_rescue'
> /opt/ree/lib/ruby/1.8/benchmark.rb:293:in `measure'
>
> Anyone have some advice for me ?
>
> Thank's in advance.
>
> Mickaël.
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---