具有多个文本输入的全文搜索

full text search with multiple text input

我正在尝试使用两个文本输入字段进行全文搜索。

 public function searchmatch()
{
     $hex = Input::get('HEX');
     $rgb = Input::get('RGB')

        $products = DB::table('products')->whereRaw(
        "MATCH(HEX,RGB) AGAINST(? IN BOOLEAN MODE)", 
        array($hex,$rgb)
    )->get();


    return view('search')->with('products', $products);
}

然而它不起作用。我尝试将两个输入都存储到一个数组中,但没有用,只有当我使用一个输入时它才有效。最好的解决方法是什么?我正在使用 Laravel 5.0。我也在整个网站上寻找解决方案,但我没有找到。

我的视图表单如下所示:

{!! Form::model(null, array('route' => array('match.search'))) !!}
<ul>
<li><div id="hex">HEX:{!! Form::text('HEX') !!}</div></li>
<li><div id="rgb">RGB:{!! Form::text('RGB') !!}</div></li>
<li><div id="picked"></div></li>
<li>{!! Form::submit('Find Match', array('id' => 'submitbtn')) !!}</li>
</ul>
{!! Form::close('Search') !!}

这是路线:

Route::post(
'matchsearch', 
 array(
 'as' => 'match.search', 
 'uses' => 'SearchController@searchmatch'
    )
 );

 class ProductsTable extends Migration {

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('products', function(Blueprint $table)
    {
        $table->increments('id');
        $table->engine = 'MyISAM';
        $table->string('name');
        $table->string('brand');
        $table->string('pathtoimage');
        $table->string('price');
        $table->text('description');
        $table->string('HEX');
        $table->string('RGB');
        $table->string('colour');
        $table->string('link');


    });
            DB::statement('ALTER TABLE products ADD FULLTEXT search(name,   brand,HEX,RGB,colour)');
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('products', function($table) {
            $table->dropIndex('search');
        });
    Schema::drop('products');
}

}

ID:1
姓名:Styletto
品牌: Lime Crime
图片路径:img/2_lime-crime-lipstick-in-styletto.jpg 价格:$18.00 描述:粗体、不透明且不计后果地填充颜料。对于胜于雄辩的嘴唇! 十六进制:#1B191B RGB:27,25,27 Colour:Black
Link:http://www.limecrime.com/unicorn-lipstick/

更新:尝试

$products = DB::table('products')
    ->whereRaw('MATCH(HEX,RGB) AGAINST(? IN BOOLEAN MODE)', array("$hex $rgb")                  
    ->get();

"$hex $rgb" - 没有 FTS 运算符意味着 $hex OR $rgb
"+$hex +rgb" - 表示 $hex AND $rgb

这是一个SQLFiddle演示

进一步阅读: