I'm hoping someone can help with the syntax for a simple query of ElasticSearch in a Laravel controller.
I have managed to index and output to a blade template in the view but I can't get the query right to enable the search form variable to perform a search on my seed data.
Search method from controller:
public function searchPlugins() {
$client = Elasticsearch\ClientBuilder::create()->build();
$query2 = Request::input('query2');
$params = [
'index' => 'partnerpages',
'type' => 'plugins',
'body' => [
'query' => $query2['query2']
]
];
$plugins = $client->search($params);
return View::make('search2')->with('plugins', $plugins);
}
I just can't get the query in the params array right - I could only get it to output for a specific field and keyword.
Any help much appreciated, thanks in advance.
EDIT
Code to output in the view in my blade template:
<!-- Search engine -->
<div class="col-md-8">
{{ Form::open(array('route' => 'search-plugins2', 'class' => 'form')) }}
{{ Form::input('search', 'query2', Input::get('query2', ''))}}
{{ Form::submit('Search plugins') }}
{{ Form:: close() }}
</div><!-- end of Search engine -->
<div class="col-md-8">
<!-- insert Search engine -->
<br/>
<h1>Plugin results</h1>
<br/>
<div class="panel panel-default">
<div class="panel-body"><h2></h2>
<div><?php print_r($plugins);?></div>
<div></div>
<div><small></small></div>
</div>
</div>
</div><!-- end of row -->