Perfect! Thank you :)

Janko

On Fri, Apr 3, 2015 at 9:02 PM Jeremy Evans <[email protected]> wrote:

> On Friday, April 3, 2015 at 10:04:22 AM UTC-7, Janko Marohnić wrote:
>>
>> Hi Jeremy,
>>
>> I'm using Sequel in combination with Sphinx. Sphinx has it's own SphinQL,
>> which is a limited version of MySQL. However, there is one clause that is
>> SphinQL-specific, and doesn't exist in the SQL language: "OPTION". Is it
>> possible to somehow append it in Sequel? I want to generate this "SQL":
>>
>> SELECT * FROM movies WHERE match('some query') OPTION field_weights=(
>> title=4, year=4);
>>
>> Note that I can't put the OPTION inside of WHERE
>> (`DB[:movies].where("MATCH (?) OPTION ...")'), because it's a separate
>> clause (and Sequel would group it with WHERE with parantheses). I also
>> can't do `DB["SELECT * FROM movies ..."]`, because when I later apply a
>> #limit, MySQL throws a syntax error.
>>
>
> My recommendation here would be to add an extension that the datasets
> could use that would change the SQL so that the OPTION clause was
> supported.  Something like:
>
>   # sequel/extensions/sphinql.rb
>   module SphinQL
>     Sequel::Dataset.def_sql_method(self, :select, %w'select distinct
> calc_found_rows columns from join where option group having compounds order
> limit lock')
>     def option(sql)
>       clone(:option => sql)
>     end
>     def select_option_sql(sql)
>       if option = opts[:option]
>         sql << " OPTION " << option
>       end
>     end
>     Sequel::Dataset.register_extension(:sphinql, self)
>   end
>
> Then you could do:
>
>   DB.extension :sphinql
>   DB[:movies].
>     where{match('some query')}.
>     option('field_weights=(title=4, year=4)')
>
> Thanks,
> Jeremy
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sequel-talk" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sequel-talk/kZIXXCYSAU4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sequel-talk.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to