Hi Richard

Glad I was able to shine some light on this issue - but what you've found is 
also absolutely correct.

I guess you'll need to do your own query term splitting and add stars in - but 
you will probably want to add hyphens as well, to avoid Sphinx treating them as 
boolean operators.

Cheers

-- 
Pat

On 25/07/2010, at 8:22 AM, Richard wrote:

> Thanks Pat,
> 
> Your dedication to dealing with the issues through this group is
> amazing.
> 
> Thanks for your advice on the below, I tried to escape the hyphen's
> with no joy. It seems it is the star_query method in search.rb which
> is causing the - to split up the query. Your funky regular expression
> is what splits it and loops the elements into individual starred
> queried such as
> 
> Sphinx   Querying: '*YS*-*RSL*-*F084*'
> 
> where I am wanting to get
> 
> Sphinx   Querying: '*YS-RSL-F084*'
> 
> Cheers
> 
> Richard
> 
> 
>   def star_query(query)
>     token = options[:star].is_a?(Regexp) ? options[:star] : /\w+/u
> 
>     query.gsub(/("#{token}(.*?#{token})?"|(?![!-])#{token})/u) do
>       pre, proper, post = $`, $&, $'
>       # E.g. "@foo", "/2", "~3", but not as part of a token
>       is_operator = pre.match(%r{(\W|^)[...@~/]\Z})
>       # E.g. "foo bar", with quotes
>       is_quote    = proper.starts_with?('"') && proper.ends_with?
> ('"')
>       has_star    = pre.ends_with?("*") || post.starts_with?("*")
>       if is_operator || is_quote || has_star
>         proper
>       else
>         "*#{proper}*"
>       end
>     end
>   end
> 
> On Jul 17, 12:03 pm, Pat Allan <[email protected]> wrote:
>> Hi Richard
>> 
>> There's no way to customise how :star behaves, so you're going to have to 
>> add the stars in yourself. Also, keep in mind that - could be treated as a 
>> special character by Sphinx if you're using the extended match mode (which 
>> is necessary for matching on certain fields - ie: the :conditions option), 
>> and so you need to escape them. Riddle.escape does this - but if you want to 
>> manage it yourself, it's just done by adding a \ in front of each -.
>> 
>> Cheers
>> 
>> --
>> Pat
>> 
>> On 17/07/2010, at 1:34 AM, Richard wrote:
>> 
>> 
>> 
>>> When searching for a product eg YS-RSL-F084 when I use :star => true
>>> in the search, looking at the logs it is actually searching for
>> 
>>> *YS*-*RSL*-*F084*
>> 
>>> So you know why this is and how to fix it??
>> 
>>> Cheers
>> 
>>> Richard
>> 
>>> --
>>> 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 
>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
> 
> -- 
> 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.
> 

-- 
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.

Reply via email to