X-Git-Url: https://git.cweiske.de/phinde.git/blobdiff_plain/226508cd8d3e8c147ad314a0de483e08be71c254..88c741c09b664260f826ff947bfaab071ac70d05:/src/phinde/Elasticsearch.php diff --git a/src/phinde/Elasticsearch.php b/src/phinde/Elasticsearch.php index 4bc4637..735b64f 100644 --- a/src/phinde/Elasticsearch.php +++ b/src/phinde/Elasticsearch.php @@ -68,7 +68,7 @@ class Elasticsearch $r->send(); } - public function search($query, $filters, $page, $perPage) + public function search($query, $filters, $site, $page, $perPage) { $r = new Elasticsearch_Request( $this->baseUrl . 'document/_search', @@ -98,6 +98,24 @@ class Elasticsearch ) ) ), + 'highlight' => array( + 'pre_tags' => array(''), + 'order' => 'score', + 'fields' => array( + 'title' => array( + 'require_field_match' => false, + 'number_of_fragments' => 0, + ), + 'url' => array( + 'require_field_match' => false, + 'number_of_fragments' => 0, + ), + 'text' => array( + 'require_field_match' => false, + 'number_of_fragments' => 1, + ), + ) + ), 'aggregations' => array( 'tags' => array( 'terms' => array( @@ -133,11 +151,20 @@ class Elasticsearch ) ); } + if ($site != '') { + $doc['query']['bool']['must'][] = array( + 'prefix' => array( + 'schemalessUrl' => array( + 'value' => $site + ) + ) + ); + } //unset($doc['_source']); //ini_set('xdebug.var_display_max_depth', 10); - //return json_decode(json_encode($doc)); + //echo json_encode($doc);die(); $r->setBody(json_encode($doc)); $res = $r->send(); return json_decode($res->getBody());