git.cweiske.de
/
phorkie.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
default operator is AND now
[phorkie.git]
/
src
/
phorkie
/
Search
/
Elasticsearch.php
diff --git
a/src/phorkie/Search/Elasticsearch.php
b/src/phorkie/Search/Elasticsearch.php
index d03ef3ecb317b3f280684b54d939d8b34be95e86..0ed766b6b68bf67cc24a9ec0a1d4ce2cde174af4 100644
(file)
--- a/
src/phorkie/Search/Elasticsearch.php
+++ b/
src/phorkie/Search/Elasticsearch.php
@@
-34,7
+34,8
@@
class Search_Elasticsearch
'should' => array(
(object)array(
'query_string' => (object)array(
'should' => array(
(object)array(
'query_string' => (object)array(
- 'query' => $term
+ 'query' => $term,
+ 'default_operator' => 'AND'
),
),
(object)array(
),
),
(object)array(
@@
-42,7
+43,8
@@
class Search_Elasticsearch
'type' => 'file',
'query' => (object)array(
'query_string' => (object)array(
'type' => 'file',
'query' => (object)array(
'query_string' => (object)array(
- 'query' => $term
+ 'query' => $term,
+ 'default_operator' => 'AND'
)
)
)
)
)
)
@@
-53,9
+55,13
@@
class Search_Elasticsearch
)
)
);
)
)
);
- //FIXME: error handling
$httpRes = $r->send();
$jRes = json_decode($httpRes->getBody());
$httpRes = $r->send();
$jRes = json_decode($httpRes->getBody());
+ if (isset($jRes->error)) {
+ throw new Exception(
+ 'Search exception: ' . $jRes->error, $jRes->status
+ );
+ }
$sres = new Search_Result();
$sres->results = $jRes->hits->total;
$sres = new Search_Result();
$sres->results = $jRes->hits->total;