Closed titoff002 closed 5 years ago
$q = '';
if ($wd)
$q .= sprintf(' +(title:(%s) tags:(%s)^0.2 recommend_text:(%s)^0.2)', $wd, $wd, $wd); // search
if ($tag)
$q = sprintf('+tags:("%s")', $tag); // full match
if ($sexuality > 0)
$q .= sprintf(' +sexuality:%s', $sexuality); // number match
if ($length) {// range math
if ($length == '*-20')
$q .= sprintf(' +length:[* TO 200000]');
}
$params = [
'index' => 'novel',
'type' => 'novel',
"q" => $q,
];
// order
if ($order == 'update') {
$params['body']['sort'] = ['novel_updated_time' => 'desc',];
} elseif ($order == 'collect') {
$params['body']['sort'] = ['collect_times' => 'desc',];
} elseif ($order == 'hot') {
$params['body']['sort'] = ['read_times' => 'desc',];
}
if ($size > 0) {
$params['size'] = $size;
}
if ($page > 1) {
$params['from'] = max(0, ($page - 1) * $size);
}
$response = $client->search($params);
$hits = $response['hits'] ?? [];
$total = $hits['total']['value'] ?? 0;
$list = [];
foreach ($hits['hits'] ?? [] as $hit) {
$list[] = $hit['_source'];
}
return [$total, $list];
Hello,
Question : how to use this elasticsearch tag "script": with elasticsearch- php ?