Created
January 24, 2017 09:10
-
-
Save firecentaur/38b89e338ca677f5f28105d87d60cbf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use Elasticsearch; | |
use Elasticsearch\ClientBuilder; | |
use Elasticsearch\Connections\Connection; | |
$client = Elasticsearch\ClientBuilder::create()->setHosts(['http://ec2-35-154-104-170.ap-south-1.compute.amazonaws.com:9200'])->build(); | |
$highlight = array( | |
"pre_tags" => array('<b>'), | |
"post_tags" => array('</b>'), | |
'fields' => array('cliptexts.content' => new \stdClass()), | |
"number_of_fragments" => 0 | |
); | |
$page = 2; | |
$params = [ | |
'index' => 'my_index2', | |
'type' => 'my_type2', | |
'body' => [ | |
'query' => [ | |
'nested' => [ | |
'path' => 'cliptexts', | |
'query' => [ | |
'match' => [ | |
'cliptexts.content' => 'eat' | |
], | |
], | |
'inner_hits' => [ | |
'highlight' => $highlight | |
] | |
], | |
], | |
'filter' => [ | |
'term' => ['uid' => 29] | |
], | |
'from' => ($page - 1) * 10, | |
'size' => 2 | |
] | |
]; | |
# $params['body']['highlight'] = $highlight; | |
$results = $client->search($params); | |
header('Content-Type: application/json'); | |
echo json_encode($results); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment