# Problem passing "WITH QUERY EXPANSION" to mysql search

**URL:** <https://www.ruby-forum.com/t/problem-passing-with-query-expansion-to-mysql-search/123760>\
**Category:** Rails\
**Created:** [December 20, 2007, 12:32pm UTC](https://www.ruby-forum.com/t/problem-passing-with-query-expansion-to-mysql-search/123760 "2007-12-20T12:32:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [December 20, 2007, 12:32pm UTC](https://www.ruby-forum.com/t/problem-passing-with-query-expansion-to-mysql-search/123760/1 "2007-12-20T12:32:14Z")

</div>

Currently my search is doing this, and works fine -

@results = item.paginate(:all, :conditions =\> [ “match(tags.name,  
#{conditions}) against (? in boolean mode)”, @search\_term ], :include =\>  
:tags, :order =\> “#{order} ASC”, :page =\> params[:page])

However, i want to use WITH QUERY EXPANSION, which returns an expanded  
search, ie returning any items which have words matching the original  
search. I thought that this should work

@results = item.paginate(:all, :conditions =\> [ “match(tags.name,  
#{conditions}) against (? in boolean mode WITH QUERY EXPANSION)”,  
@search\_term ], :include =\> :tags, :order =\> “#{order} ASC”, :page =\>  
params[:page])

but it’s crashing with this error -

Mysql::Error: 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 ‘WITH QUERY EXPANSION))’ at line 1: SELECT count(DISTINCT  
learningpaths.id) AS count\_all FROM learningpaths LEFT OUTER JOIN  
taggings ON (learningpaths.`id` = taggings.`taggable_id` AND  
taggings.`taggable_type` = ‘Learningpath’) LEFT OUTER JOIN tags ON  
(tags.`id` = taggings.`tag_id`) WHERE (match(tags.name,  
learningpaths.name, learningpaths.description) against (’+trumpet  
+beginners’ in boolean mode WITH QUERY EXPANSION))

Looking at the mysql search it tried to do, it looks fine to me - can  
anyone see a problem with how “with query expansion” is being used?

thanks  
max
