I have integrated elastic search in laravel with help of below tutorial.
https://appdividend.com/2018/06/30/laravel-elasticsearch-tutorial-example/
According to this tutorial search with single fields is working fine. i.e.
// Article table has column 'title','body' and 'tags'.
Route::get('/search', function() {
$articles = Article::searchByQuery(['match' => ['title' => 'Test']]);
return $articles;
});
But i want to search with multiple column values like 'title' ,'body' etc.
Anyone suggest an idea how to search with multiple column?
You can use the multimatch query, below is some sample how this can be done.
GET _search
{
"query": {
"bool": {
"must": {
"multi_match" : {
"query": "stuff you want to seach",
"type": "cross_fields",
"fields": [
"title^10",
"body^9",
"tags^8"
]
}
}
}
}
}