lundi 16 mars 2020

how to implement Elastic Search in Laravel for auto complete

I followed this wonderful tutorial Made with love ES laravel tutorial to implement ES in my Laravel Ecommerce app i am building. I got it to work but i wanted to tweak it a little because as of now, the results only work when i my query term matches exactly an entire word i have in one of my products.

i have a health nut bar called bear naked almond bar, but when i type "bea" it doesn't match anything, but when i type "bear" then it works.

This is my search query as of now.

        $model = new ProductsListing;

        $items = $this->elasticsearch->search([
            'index' => $model->getSearchIndex(),
            'type' => $model->getSearchType(),
            'body' => [
                'query' => [
                    'multi_match' => [
                        'fields' => ['brand', 'name^5', 'description'],
                        'query' => $query,
                    ],
                ],
            ],
        ]);

I would need some help to adjust the query so that i get results as i type.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2J4BcnH
via IFTTT

Aucun commentaire:

Enregistrer un commentaire