aboutsummaryrefslogtreecommitdiff
path: root/src/phinde/Elasticsearch.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2016-02-03 21:12:17 +0100
committerChristian Weiske <cweiske@cweiske.de>2016-02-03 21:12:17 +0100
commit88c741c09b664260f826ff947bfaab071ac70d05 (patch)
treeb2f7417aee5979d4bd994b929f71d518a3604aa0 /src/phinde/Elasticsearch.php
parentfab8cabe19ac99e3c8a95abcea3c0569b67045bb (diff)
downloadphinde-88c741c09b664260f826ff947bfaab071ac70d05.tar.gz
phinde-88c741c09b664260f826ff947bfaab071ac70d05.zip
add site search, highlighting
Diffstat (limited to 'src/phinde/Elasticsearch.php')
-rw-r--r--src/phinde/Elasticsearch.php31
1 files changed, 29 insertions, 2 deletions
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('<em class="hl">'),
+ '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());