Skip to content

Latest commit

 

History

History
executable file
·
34 lines (26 loc) · 947 Bytes

debugging.md

File metadata and controls

executable file
·
34 lines (26 loc) · 947 Bytes

#Debugging Sometimes you might wonder why certain results are or aren't returned.

Here is an example from the ElasticVision demo app, although not with a complex query:

class SearchController
{
    public function __invoke(SearchFormRequest $request)
    {
        $people = Cartographer::search($request->get('keywords'))->get();

        return view('search', [
            'people' => $people,
        ]);
    }
}

To debug this search query you can call the static debug method on the Elastic Engine for Laravel Scout:

use Hilsonxhero\ElasticVision\Infrastructure\Scout\ElasticEngine;

$debug = ElasticEngine::debug();

The debug class that this method returns can give you the last executed query as an array or as json. You should be able to copy-paste the json as a direct query to Elasticsearch.

$lastQueryAsArray = ElasticEngine::debug()->array();
$lastQueryAsJson = ElasticEngine::debug()->json();