match against ...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

match against ...

RAPPAZ Francois
Hi there

I haven't look deep enough in the doc pages, sorry, but how can I translate this with resultset('table')->search_rs();

SELECT * FROM table WHERE match(field1, field2, field3) against('+$bla' in boolean mode) ORDER BY field1 ?

$bla being taken from a field and having the spaces substituted with + :

my $bla = $b->get_text();

($bla=$bla)=~s/\s+/ \+/g;

Thanks

François

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

Hailin Hu
Hi,

Have a look at docs below:
http://search.cpan.org/~ribasushi/DBIx-Class-0.08270/lib/DBIx/Class/ResultSet.pm#where
http://search.cpan.org/~ribasushi/SQL-Abstract-1.77/lib/SQL/Abstract.pm#SPECIAL_OPERATORS

On Sat, Mar 29, 2014 at 12:46 AM, RAPPAZ Francois
<[hidden email]> wrote:

> Hi there
>
> I haven't look deep enough in the doc pages, sorry, but how can I translate this with resultset('table')->search_rs();
>
> SELECT * FROM table WHERE match(field1, field2, field3) against('+$bla' in boolean mode) ORDER BY field1 ?
>
> $bla being taken from a field and having the spaces substituted with + :
>
> my $bla = $b->get_text();
>
> ($bla=$bla)=~s/\s+/ \+/g;
>
> Thanks
>
> François
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@...

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

RAPPAZ Francois
I'm struggling with code as

        #sql I want to is SELECT * FROM jrn WHERE match(ti, ex, ad) against('+$bla' in boolean mode) ORDER BY tri");

  $bla is a string that holds the text to search
 
 my $sqlmaker = SQL::Abstract->new(special_ops => [  {regex => qr/^match$/i,
     handler => sub {
       my ($me, $field, $op, $arg) = @_;
       $arg = [$arg] if not ref $arg;
       my $label         = $me->_quote($field);
       my ($placeholder) = $me->_convert('?');
       my $placeholders  = join ", ", (($placeholder) x @$arg);
       my $sql           = $me->_sqlcase('match') . " ($label) " . $me->_sqlcase('against') . " ($placeholders) ";
       my @bind = $me->_bindtype($field, @$arg);
       return ($sql, @bind);
       }
     },
  ]);
       
        my ($where, @bind)= $sqlmaker->where("ti, ex, ad", "tri", $bla);
$self->{log}->debug($where);
         my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef, {where=> $where});

But keep having error message. What is @bind for if I don't use it ?

Thanks for showing the right way to have this !

François


> -----Original Message-----
> From: Hailin Hu [mailto:[hidden email]]
> Sent: vendredi, 28. mars 2014 18:36
> To: DBIx::Class user and developer list
> Subject: Re: [Dbix-class] match against ...
>
> Hi,
>
> Have a look at docs below:
> http://search.cpan.org/~ribasushi/DBIx-Class-
> 0.08270/lib/DBIx/Class/ResultSet.pm#where
> http://search.cpan.org/~ribasushi/SQL-Abstract-
> 1.77/lib/SQL/Abstract.pm#SPECIAL_OPERATORS
>
> On Sat, Mar 29, 2014 at 12:46 AM, RAPPAZ Francois
> <[hidden email]> wrote:
> > Hi there
> >
> > I haven't look deep enough in the doc pages, sorry, but how can I
> > translate this with resultset('table')->search_rs();
> >
> > SELECT * FROM table WHERE match(field1, field2, field3)
> against('+$bla' in boolean mode) ORDER BY field1 ?
> >
> > $bla being taken from a field and having the spaces substituted with
> + :
> >
> > my $bla = $b->get_text();
> >
> > ($bla=$bla)=~s/\s+/ \+/g;
> >
> > Thanks
> >
> > François
> >
> > _______________________________________________
> > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> > IRC: irc.perl.org#dbix-class
> > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> > Searchable Archive:
> > http://www.grokbase.com/group/dbix-class@...
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-
> [hidden email]

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

Hailin Hu
You should at least give out the error message if you expect any
feedback from others.

Others will not create a same environment as yours and run the codes
you pasted. Generally, they just analyze the problem with the
description only. Me, too :)

On Wed, Apr 2, 2014 at 6:47 PM, RAPPAZ Francois
<[hidden email]> wrote:

> I'm struggling with code as
>
>         #sql I want to is SELECT * FROM jrn WHERE match(ti, ex, ad) against('+$bla' in boolean mode) ORDER BY tri");
>
>   $bla is a string that holds the text to search
>
>  my $sqlmaker = SQL::Abstract->new(special_ops => [  {regex => qr/^match$/i,
>      handler => sub {
>        my ($me, $field, $op, $arg) = @_;
>        $arg = [$arg] if not ref $arg;
>        my $label         = $me->_quote($field);
>        my ($placeholder) = $me->_convert('?');
>        my $placeholders  = join ", ", (($placeholder) x @$arg);
>        my $sql           = $me->_sqlcase('match') . " ($label) " . $me->_sqlcase('against') . " ($placeholders) ";
>        my @bind = $me->_bindtype($field, @$arg);
>        return ($sql, @bind);
>        }
>      },
>   ]);
>
>         my ($where, @bind)= $sqlmaker->where("ti, ex, ad", "tri", $bla);
> $self->{log}->debug($where);
>          my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef, {where=> $where});
>
> But keep having error message. What is @bind for if I don't use it ?
>
> Thanks for showing the right way to have this !
>
> François
>
>
>> -----Original Message-----
>> From: Hailin Hu [mailto:[hidden email]]
>> Sent: vendredi, 28. mars 2014 18:36
>> To: DBIx::Class user and developer list
>> Subject: Re: [Dbix-class] match against ...
>>
>> Hi,
>>
>> Have a look at docs below:
>> http://search.cpan.org/~ribasushi/DBIx-Class-
>> 0.08270/lib/DBIx/Class/ResultSet.pm#where
>> http://search.cpan.org/~ribasushi/SQL-Abstract-
>> 1.77/lib/SQL/Abstract.pm#SPECIAL_OPERATORS
>>
>> On Sat, Mar 29, 2014 at 12:46 AM, RAPPAZ Francois
>> <[hidden email]> wrote:
>> > Hi there
>> >
>> > I haven't look deep enough in the doc pages, sorry, but how can I
>> > translate this with resultset('table')->search_rs();
>> >
>> > SELECT * FROM table WHERE match(field1, field2, field3)
>> against('+$bla' in boolean mode) ORDER BY field1 ?
>> >
>> > $bla being taken from a field and having the spaces substituted with
>> + :
>> >
>> > my $bla = $b->get_text();
>> >
>> > ($bla=$bla)=~s/\s+/ \+/g;
>> >
>> > Thanks
>> >
>> > François
>> >
>> > _______________________________________________
>> > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
>> > IRC: irc.perl.org#dbix-class
>> > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
>> > Searchable Archive:
>> > http://www.grokbase.com/group/dbix-class@...
>>
>> _______________________________________________
>> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
>> IRC: irc.perl.org#dbix-class
>> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
>> Searchable Archive: http://www.grokbase.com/group/dbix-
>> [hidden email]
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@...

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

RAPPAZ Francois
*** unhandled exception in callback:
***   DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'WHERE ( ti, ex, ad ) ORDER BY tri )' at line 1
[for Statement "SELECT me.nofm FROM jrn me WHERE (  WHERE ( ti, ex, ad ) ORDER BY tri )"] at Linker/DbcDataManager.pm line 234

The where clause is wrong: match and against are missing It's a question of my lack of understanding of the documentation for SQL::Abstract and it's use with search_rs

François

> -----Original Message-----
> From: Hailin Hu [mailto:[hidden email]]
> Sent: jeudi, 3. avril 2014 05:52
> To: DBIx::Class user and developer list
> Subject: Re: [Dbix-class] match against ...
>
> You should at least give out the error message if you expect any
> feedback from others.
>
> Others will not create a same environment as yours and run the codes
> you pasted. Generally, they just analyze the problem with the
> description only. Me, too :)
>
> On Wed, Apr 2, 2014 at 6:47 PM, RAPPAZ Francois
> <[hidden email]> wrote:
> > I'm struggling with code as
> >
> >         #sql I want to is SELECT * FROM jrn WHERE match(ti, ex, ad)
> > against('+$bla' in boolean mode) ORDER BY tri");
> >
> >   $bla is a string that holds the text to search
> >
> >  my $sqlmaker = SQL::Abstract->new(special_ops => [  {regex =>
> qr/^match$/i,
> >      handler => sub {
> >        my ($me, $field, $op, $arg) = @_;
> >        $arg = [$arg] if not ref $arg;
> >        my $label         = $me->_quote($field);
> >        my ($placeholder) = $me->_convert('?');
> >        my $placeholders  = join ", ", (($placeholder) x @$arg);
> >        my $sql           = $me->_sqlcase('match') . " ($label) " .
> $me->_sqlcase('against') . " ($placeholders) ";
> >        my @bind = $me->_bindtype($field, @$arg);
> >        return ($sql, @bind);
> >        }
> >      },
> >   ]);
> >
> >         my ($where, @bind)= $sqlmaker->where("ti, ex, ad", "tri",
> > $bla); $self->{log}->debug($where);
> >          my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef,
> > {where=> $where});
> >
> > But keep having error message. What is @bind for if I don't use it ?
> >
> > Thanks for showing the right way to have this !
> >
> > François
> >
> >
> >> -----Original Message-----
> >> From: Hailin Hu [mailto:[hidden email]]
> >> Sent: vendredi, 28. mars 2014 18:36
> >> To: DBIx::Class user and developer list
> >> Subject: Re: [Dbix-class] match against ...
> >>
> >> Hi,
> >>
> >> Have a look at docs below:
> >> http://search.cpan.org/~ribasushi/DBIx-Class-
> >> 0.08270/lib/DBIx/Class/ResultSet.pm#where
> >> http://search.cpan.org/~ribasushi/SQL-Abstract-
> >> 1.77/lib/SQL/Abstract.pm#SPECIAL_OPERATORS
> >>
> >> On Sat, Mar 29, 2014 at 12:46 AM, RAPPAZ Francois
> >> <[hidden email]> wrote:
> >> > Hi there
> >> >
> >> > I haven't look deep enough in the doc pages, sorry, but how can I
> >> > translate this with resultset('table')->search_rs();
> >> >
> >> > SELECT * FROM table WHERE match(field1, field2, field3)
> >> against('+$bla' in boolean mode) ORDER BY field1 ?
> >> >
> >> > $bla being taken from a field and having the spaces substituted
> >> > with
> >> + :
> >> >
> >> > my $bla = $b->get_text();
> >> >
> >> > ($bla=$bla)=~s/\s+/ \+/g;
> >> >
> >> > Thanks
> >> >
> >> > François
> >> >
> >> > _______________________________________________
> >> > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> >> > IRC: irc.perl.org#dbix-class
> >> > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> >> > Searchable Archive:
> >> > http://www.grokbase.com/group/dbix-class@...
> >>
> >> _______________________________________________
> >> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> >> IRC: irc.perl.org#dbix-class
> >> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> >> Searchable Archive: http://www.grokbase.com/group/dbix-
> >> [hidden email]
> >
> > _______________________________________________
> > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> > IRC: irc.perl.org#dbix-class
> > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> > Searchable Archive:
> > http://www.grokbase.com/group/dbix-class@...
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-
> [hidden email]

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

Will Crawford
In reply to this post by RAPPAZ Francois
On 2 April 2014 10:47, RAPPAZ Francois <[hidden email]> wrote:
> I'm struggling with code as
...
>         my ($where, @bind)= $sqlmaker->where("ti, ex, ad", "tri", $bla);
> $self->{log}->debug($where);
>          my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef, {where=> $where});

Couple of things that might help:
· you don't seem to be passing anything into $sqlmaker->where(...)
that would match the regex you provided for special_ops (so how would
it know to create your "match ... against" sql)
· you'll probably need to pass the SQL into DBIC as { where => \[
$sql, @binds ] }

This may or may not be enough. A (much simpler) example that works for me is:

    my $user = $rs->search( undef, { where => \[ 'id = ?', [ id =>
52521 ] ] } )->first;

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

RAPPAZ Francois
Thanks for replying !

My code is now

 my $sqlmaker = SQL::Abstract->new(special_ops => [  {regex => qr/^match$/i,
     handler => sub{
        my ($me, $field, $op, $arg) = @_;
       $arg = [$arg] if not ref $arg;
       my $label         = $me->_quote($field);
       my ($placeholder) = $me->_convert('?');
       my $placeholders  = join ", ", (($placeholder) x @$arg);
       my $sql           = $me->_sqlcase('match') . " ($label) " . $me->_sqlcase('against') . " ($placeholders) ";
       my @bind = $me->_bindtype($field, @$arg);
       return ($sql, @bind);
     },
     },
  ]);
#this line is suggested by the reply in this page
#http://nailingjelly.wordpress.com/2009/05/11/extending-sqlabstract/

my ($where, @bind)= $sqlmaker->where ({"ti, ex, ad" => {-match =>  $bla}});

my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef, {where=>\[$where, @bind], order_by => 'tri'});

I still have an error
***   DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st
execute failed: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near

'WHERE ( MATCH (ti, ex, ad) AGAINST ('test')  ) ) ORDER BY tri'

at line 1 [for Statement
"SELECT me.nofm FROM jrn me WHERE (  WHERE ( MATCH (ti, ex, ad) AGAINST (?)  ) )
ORDER BY tri" with ParamValues: 0="test"]
at ...

If one test the where clause in phpmyadmin, one see that there the parenthesis are not balanced ( ()() )).

Is it the way I'm calling using the sqlmaker object ?


Thanks for any suggestion

François

> -----Original Message-----
> From: Will Crawford [mailto:[hidden email]]
> Sent: jeudi, 3. avril 2014 11:56
> To: DBIx::Class user and developer list
> Subject: Re: [Dbix-class] match against ...
>
> On 2 April 2014 10:47, RAPPAZ Francois <[hidden email]>
> wrote:
> > I'm struggling with code as
> ...
> >         my ($where, @bind)= $sqlmaker->where("ti, ex, ad", "tri",
> > $bla); $self->{log}->debug($where);
> >          my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef,
> > {where=> $where});
>
> Couple of things that might help:
> · you don't seem to be passing anything into $sqlmaker->where(...) that
> would match the regex you provided for special_ops (so how would it
> know to create your "match ... against" sql) · you'll probably need to
> pass the SQL into DBIC as { where => \[ $sql, @binds ] }
>
> This may or may not be enough. A (much simpler) example that works for
> me is:
>
>     my $user = $rs->search( undef, { where => \[ 'id = ?', [ id =>
> 52521 ] ] } )->first;
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-
> [hidden email]
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

Will Crawford
On 3 April 2014 13:37, RAPPAZ Francois <[hidden email]> wrote:
> Is it the way I'm calling using the sqlmaker object ?

It occurs to me that DBIC is cheerfully calling into sqlfairy behind
the scenes and turning your already-formatted SQL into its own where
clause. Maybe try:

->search( \[ $sql, @binds ] )

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

Peter Rabbitson-2
In reply to this post by RAPPAZ Francois
On Fri, Mar 28, 2014 at 03:46:05PM +0000, RAPPAZ Francois wrote:
> Hi there
>
> I haven't look deep enough in the doc pages, sorry, but how can I translate this with resultset('table')->search_rs();
>
> SELECT * FROM table WHERE match(field1, field2, field3) against('+$bla' in boolean mode) ORDER BY field1 ?

Sorry for the late reply. There is no multi-parameter op support in SQLA
yet, due to the complexity of the corner cases (as you already
discovered). As suggested earlier in the thread - simply tell DBIC "in
this particular snippet - I'll drive":

->search(
  {
    criteria1 => val1,
    criteria2 => val2,
    -and => [
      \[ $sql, @bind ],
      \[ $more_sql, @more_bind ],
    ]
  },
  {
    order_by => ...
    prefetch => ...
    ...
  },
);

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

RAPPAZ Francois
I tried
my @b; push @b, $bla;
my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef, { -and => [ \["WHERE match(ti, ex, ad)  against(? in boolean mode)", @b]], order_by => 'tri'});

and gets all the table back, not the row matching the criteria.

Sorry but I really new to all these DBiC things.

You mean there is no need to use SQL::Abstract at all ? or the $sql value are coming from there ?

Could you be more explicit ?

Thanks
François


> -----Original Message-----
> From: Peter Rabbitson [mailto:[hidden email]]
> Sent: jeudi, 3. avril 2014 16:04
> To: DBIx::Class user and developer list
> Subject: Re: [Dbix-class] match against ...
>
> On Fri, Mar 28, 2014 at 03:46:05PM +0000, RAPPAZ Francois wrote:
> > Hi there
> >
> > I haven't look deep enough in the doc pages, sorry, but how can I
> > translate this with resultset('table')->search_rs();
> >
> > SELECT * FROM table WHERE match(field1, field2, field3)
> against('+$bla' in boolean mode) ORDER BY field1 ?
>
> Sorry for the late reply. There is no multi-parameter op support in
> SQLA yet, due to the complexity of the corner cases (as you already
> discovered). As suggested earlier in the thread - simply tell DBIC "in
> this particular snippet - I'll drive":
>
> ->search(
>   {
>     criteria1 => val1,
>     criteria2 => val2,
>     -and => [
>       \[ $sql, @bind ],
>       \[ $more_sql, @more_bind ],
>     ]
>   },
>   {
>     order_by => ...
>     prefetch => ...
>     ...
>   },
> );
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-
> [hidden email]

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

Will Crawford
On 4 April 2014 15:27, RAPPAZ Francois <[hidden email]> wrote:
> I tried
...
> my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef, { -and => [ \["WHERE match(ti, ex, ad)  against(? in boolean mode)", @b]], order_by => 'tri'});

Take out the "undef, " -- you've passed the query as the second parameter.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: match against ...

RAPPAZ Francois
At the end, this was working

        my $bla = $b->get_text();
        ($bla=$bla)=~s/\s+/ \+/g;
        my @b;
        push @b, $bla;
        my $rs = $self->{schema}->resultset('Jrn')->search(\[ "match (ti, ex, ad) against(? in boolean mode)", @b], {order_by => 'tri'});

F.

> -----Original Message-----
> From: Will Crawford [mailto:[hidden email]]
> Sent: vendredi, 4. avril 2014 16:57
> To: DBIx::Class user and developer list
> Subject: Re: [Dbix-class] match against ...
>
> On 4 April 2014 15:27, RAPPAZ Francois <[hidden email]>
> wrote:
> > I tried
> ...
> > my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef, { -and
> => [ \["WHERE match(ti, ex, ad)  against(? in boolean mode)", @b]],
> order_by => 'tri'});
>
> Take out the "undef, " -- you've passed the query as the second
> parameter.
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-
> [hidden email]

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...