Skip to content

Instantly share code, notes, and snippets.

@diloabininyeri
Created November 13, 2018 09:59
Show Gist options
  • Save diloabininyeri/9bf6ccee457439e45757fae94e039ca7 to your computer and use it in GitHub Desktop.
Save diloabininyeri/9bf6ccee457439e45757fae94e039ca7 to your computer and use it in GitHub Desktop.
<?php
require_once "vendor/autoload.php";
use Elasticsearch\ClientBuilder;
$client = ClientBuilder::create()->build();
$res = $client->search([
'index' => 'accounts',
'type' => 'person',
'body' => ["query" => [
"multi_match" => [
"query" => $_GET['q'],
"fields" => ["name^2", "lastname^1", "job_description^1"],
"slop" => 1,
"minimum_should_match" => 1
]
]
]
]);
echo '<pre>';
print_r($res['hits']['hits']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment