# Laravel Scout Elastic

**URL:** <https://discuss.elastic.co/t/laravel-scout-elastic/140349>\
**Category:** Elasticsearch\
**Created:** [July 17, 2018, 2:51pm UTC](https://discuss.elastic.co/t/laravel-scout-elastic/140349 "2018-07-17T14:51:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ademozmermer](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@ademozmermer](https://discuss.elastic.co/u/ademozmermer)\
**Post date:** [July 17, 2018, 2:51pm UTC](https://discuss.elastic.co/t/laravel-scout-elastic/140349/1 "2018-07-17T14:51:33Z")

</div>

Hello. I use the [https://packagist.org/packages/tamayo/laravel-scout-elastic](https://packagist.org/packages/tamayo/laravel-scout-elastic) package for Laravel Scout Elastic. I had to write a closure function to use fuzzy. My problem is that I need to get the true values ​​in the Internet column of the table I query, but Model::search (...)-\>where('internet', 1) fetches all records. Although I have done a lot of research, I have not found a solution yet. Some of the methods I have tried are as follows.

```
    $products = Products::search($request->get('query'),
        function (\Elasticsearch\Client $client, $query, $params) {
            $params['body']['query'] = [
                'multi_match' => [
                    'query' => $query,
                    'fuzziness' => 'AUTO',
                    'fields' => ['name^3', 'brand'],
                ], ];

            return $client->search($params);
        }
    )->where('internet', 1)->paginate(20);

    $products = Products::where('internet', 1)->search($request->get('query'),
        function (\Elasticsearch\Client $client, $query, $params) {
            $params['body']['query'] = [
                'multi_match' => [
                    'query' => $query,
                    'fuzziness' => 'AUTO',
                    'fields' => ['name^3', 'brand'],
                ], ];

            return $client->search($params);
        }
    )->paginate(20);

      $products = Products::search($request->get('query'),
        function (\Elasticsearch\Client $client, $query, $params) {
            $params['body']['query'] = [
                'multi_match' => [
                    'query' => $query,
                    'fuzziness' => 'AUTO',
                    'fields' => ['name^3', 'brand'],
                ],
                'filter' => [
                      'term' => ['internet' => 1]
                ] ];

            return $client->search($params);
        }
    )->where('internet', 1)->paginate(20);

```

I'm sorry for my bad english.

---

<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:** [August 14, 2018, 2:51pm UTC](https://discuss.elastic.co/t/laravel-scout-elastic/140349/2 "2018-08-14T14:51:37Z")

</div>

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