拉威尔+;Mongodb全文搜索

拉威尔+;Mongodb全文搜索,mongodb,laravel,Mongodb,Laravel,如何使mongodb文本搜索在Laravel中工作?请建议 我可以在候机楼做- db.coupons.find( { $text: { $search: "Search me here" } } ) 但不知道如何在laravel中实现它。在composer.json中添加软件包,并通过composer update安装该软件包。访问添加的链接,您将获得处理mongodb laravel连接的良好来源 你有没有试过这样的方法: $users = User::with(array('posts'

如何使mongodb文本搜索在Laravel中工作?请建议

我可以在候机楼做-

db.coupons.find( { $text: { $search: "Search me here" } } )
但不知道如何在laravel中实现它。

在composer.json中添加软件包,并通过
composer update安装该软件包。访问添加的链接,您将获得处理mongodb laravel连接的良好来源

你有没有试过这样的方法:

$users = User::with(array('posts' => function($query)
{
    $query->where('title', 'like', '%first%');

}))->get();
看看这是否有帮助

在composer.json中添加软件包,并通过
composer update
安装该软件包。访问添加的链接,您将获得处理mongodb laravel连接的良好来源

你有没有试过这样的方法:

$users = User::with(array('posts' => function($query)
{
    $query->where('title', 'like', '%first%');

}))->get();
看看这是否有帮助

由于您正在使用,根据您的代码,您可以说

$coups=coups::where(“$text”=>[“$search”=>“在这里搜索我])

}))->get()

由于您正在使用,根据您的代码,您可以说

$coups=coups::where(“$text”=>[“$search”=>“在这里搜索我])


}))->get()

要使用laravel mongodb(使用jenssegers/laravel mongodb)进行搜索,您需要首先创建索引。例如:
db.articles.createIndex({“subject”:“text”})
,其中
subject
是进行搜索的文本属性

然后,您可以在mongodb:
db.articles.find({$text:{$search:{$coffee}})
中尝试查询,或者在Laravel中进行查询:

$word = "coffee";
$response = Article::whereRaw(array('$text'=>array('$search'=> $word)))->get();
如果你想搜索一个短语,你需要使用引号。在mongodb中:
db.articles.find({$text:{$search:“\'coffee shop\”“}})
和Laravel:

$word = "coffee shop";
$response = Article::whereRaw(array('$text'=>array('$search'=> "\"" . $word . "\"")))->get();

要使用laravel mongodb(使用jenssegers/laravel mongodb)进行搜索,您需要首先创建索引。例如:
db.articles.createIndex({“subject”:“text”})
,其中
subject
是进行搜索的文本属性

然后,您可以在mongodb:
db.articles.find({$text:{$search:{$coffee}})
中尝试查询,或者在Laravel中进行查询:

$word = "coffee";
$response = Article::whereRaw(array('$text'=>array('$search'=> $word)))->get();
如果你想搜索一个短语,你需要使用引号。在mongodb中:
db.articles.find({$text:{$search:“\'coffee shop\”“}})
和Laravel:

$word = "coffee shop";
$response = Article::whereRaw(array('$text'=>array('$search'=> "\"" . $word . "\"")))->get();

我已经在用了。但不知道如何使用全文搜索。我已经在使用它了。但不知道如何使用全文搜索。