X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/1a8bb56c72ad34cf159e03b97a467e5e35a614c5..fce55a36d47a9783e631a78925f2ad1b28dbe555:/src/phorkie/Search/Elasticsearch.php?ds=sidebyside diff --git a/src/phorkie/Search/Elasticsearch.php b/src/phorkie/Search/Elasticsearch.php index d03ef3e..0ed766b 100644 --- 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( - 'query' => $term + 'query' => $term, + 'default_operator' => 'AND' ), ), (object)array( @@ -42,7 +43,8 @@ class Search_Elasticsearch '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()); + if (isset($jRes->error)) { + throw new Exception( + 'Search exception: ' . $jRes->error, $jRes->status + ); + } $sres = new Search_Result(); $sres->results = $jRes->hits->total;