I am trying to connect elasticsearch server to work on my localhost (real-estate-laravel.test). I downloaded and activated elasticsearch and have elastichsearch server running on http://localhost:9200/ , like this
{
"name" : "DESKTOP-F9QAVC4",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "5br4u4tTTR-xzg7FBeInPg",
"version" : {
"number" : "7.3.0",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "de777fa",
"build_date" : "2019-07-24T18:30:11.767338Z",
"build_snapshot" : false,
"lucene_version" : "8.1.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
And I added in my composer.json
"require": {
"elasticsearch/elasticsearch": "^7.0"
}
and entered composer update. I am now confused on how to connect elasticsearch server with my localhost, so when I make some search queries in my controller they will search through elasticsearch. Any help is appreciated. Here is my controller.
CategoryController.php
<?php
namespace App\Http\Controllers;
use App\User;
use App\Category;
use App\Property;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cookie;
use Elasticsearch\ClientBuilder;
class CategoryController extends Controller
{
public function search(Category $category, Property $property, User $user)
{
$client = ClientBuilder::create()->build();
//dd($client);
if(Auth::check())
{
}
}
}
In this if(Auth::check()) will go certain queries. Also when I dump $client I get this
Client {#351 ▼
+transport: Transport {#349 ▶}
#params: null
#indices: IndicesNamespace {#352 ▶}
#cluster: ClusterNamespace {#353 ▶}
#nodes: NodesNamespace {#354 ▶}
#snapshot: SnapshotNamespace {#355 ▶}
#cat: CatNamespace {#356 ▶}
#ingest: IngestNamespace {#357 ▶}
#tasks: TasksNamespace {#358 ▶}
#remote: RemoteNamespace {#359 ▶}
#endpoints: Closure($class) {#350 ▶}
#registeredNamespaces: []
}