Beispiel #1
0
function get_occurrences($es, $db, $spp)
{
    $synonyms = search($es, $db, "taxon", "acceptedNameUsage:\"" . $spp . "*\" AND taxonomicStatus:\"synonym\"");
    $q = "acceptedNameUsage:\"{$spp}*\" OR scientificName:\"{$spp}*\" OR scientificNameWithoutAuthorship: \"{$spp}*\"";
    foreach ($synonyms as $syn) {
        $spp_syn = $syn->scientificNameWithoutAuthorship;
        $q .= " OR acceptedNameUsage:\"{$spp_syn}*\" OR scientificName:\"{$spp_syn}*\" OR scientificNameWithoutAuthorship:\"{$spp_syn}*\"";
        $spp_syn = $syn->scientificName;
        $q .= " OR acceptedNameUsage:\"{$spp_syn}*\" OR scientificName:\"{$spp_syn}*\" OR scientificNameWithoutAuthorship:\"{$spp_syn}*\"";
    }
    $docs = [];
    $hits = search_post(ELASTICSEARCH, $db, 'occurrence', $q);
    foreach ($hits as $hit) {
        unset($hit->_rev);
        $docs[] = $hit;
    }
    return $docs;
}
<?php

$k = $_GET["k"];
$sotin1trang = 12;
$trang = $_GET["trang"];
settype($trang, "int");
if ($trang <= 0) {
    $trang = 1;
}
$tongtin = search_post($k);
$tongsotin = mysql_num_rows($tongtin);
$sotrang = ceil($tongsotin / $sotin1trang);
?>
<div class="title_style">TÌM KIẾM BÀI VIẾT</div>
<div class="wrap_page_act">
	<div class="search_block">
    <form action="main-page.php" name="form_search" id="form_search">
    <div style="padding:20px; line-height:25px">
    <label>Tìm kiếm bài viết</label>
    <input type="hidden" name="p" value="search-post" />
    <input type="text" name="k" placeholder="Nhập từ khóa cần tìm...">
    <input type="submit" class="button_style1" value="Tìm kiếm" />
    </div>
    </form>
    </div>
	<div id="usual1" class="usual"> 
              <ul> 
                <li><a href="#tab1">BÀI VIẾT</a></li> 
              </ul> 
              
              <div class="tab_content" id="tab1">