1
私は弾性検索-phpで私の結果を強調しようとしています。知識とGoogleで検索してみましたが、同じ質問はセンスで完璧に働いていません。ある意味では、私のクエリは私が必要なものを引き起こす正確な取得上記のクエリと弾性検索の結果を強調表示する
GET /bank/account/_search
{
"query" : {
"match_phrase" : {
"address" : "mill"
}
},
"highlight": {
"pre_tags" : ["<tag1>"],
"post_tags" : ["</tag1>"],
"fields" : {
"address" : {}
}
}
}
で、これは私は私が強調された結果を得るわけではないのPHPを使用して、同じクエリを試してみました
highlight": {
"address": [
"990 <tag1>Mill</tag1> Road"
]
}
を得た結果は、私のPHPのクエリは
<?php
require 'vendor/autoload.php';
$client=new Elasticsearch\Client();
$indexParams = [
'index' => 'bank',
'type' => 'account',
'body' => [
'query' => [
'match' => [
"address" => "mill"
],
],
'highlight' => [
"pre_tags" => "<tag1>",
"post_tags" => "</tag1>",
'fields' => [
'address' => new \stdClass()
]
],
]
];
$results = $client->search($indexParams);
try {
$response = $client->search($indexParams);
} catch (Exception $e) {
var_dump($e->getMessage());
}
echo '<pre>',print_r($response),'</pre>';
?>
私が取得AAM結果
[highlight] => Array
(
[address] => Array
(
[0] => 715 Mill Avenue
)
)
です