# How to pass search query to elasticsearch from laravel controller

**URL:** <https://discuss.elastic.co/t/how-to-pass-search-query-to-elasticsearch-from-laravel-controller/126495>\
**Category:** Elasticsearch\
**Created:** [April 3, 2018, 3:58am UTC](https://discuss.elastic.co/t/how-to-pass-search-query-to-elasticsearch-from-laravel-controller/126495 "2018-04-03T03:58:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![divya757](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@divya757](https://discuss.elastic.co/u/divya757)\
**Post date:** [April 3, 2018, 3:58am UTC](https://discuss.elastic.co/t/how-to-pass-search-query-to-elasticsearch-from-laravel-controller/126495/1 "2018-04-03T03:58:01Z")

</div>

i am working on this one but it is not working , i am using aws elasticsearch 6.2

$hosts=[  
'host' =\> 'localhost(here i am using aws end point)'  
];  
$client = ClientBuilder::create() -\>setHosts($hosts) -\>build();

$json = '{  
"query" : {  
"match" : {  
"title" : "phone"  
}  
}  
}';

$params['index'] = 'sainikad';  
$params['type'] = 'ads';  
$params['body'] = $json;

$results=$client-\>search($params);

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 1, 2018, 3:58am UTC](https://discuss.elastic.co/t/how-to-pass-search-query-to-elasticsearch-from-laravel-controller/126495/2 "2018-05-01T03:58:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
