elasticsearch-php icon indicating copy to clipboard operation
elasticsearch-php copied to clipboard

Fix suggestion endpoint in 6.x Client

Open tdashton opened this issue 8 years ago • 5 comments

Summary of problem or feature request

in the 6.0.1 tag and master of the driver code the \Elasticsearch\Endpoints\Suggest is broken.

Suggested fix is:

diff --git a/src/Elasticsearch/Endpoints/Suggest.php b/src/Elasticsearch/Endpoints/Suggest.php
index 1afb1f2..8fecc7f 100644
--- a/src/Elasticsearch/Endpoints/Suggest.php
+++ b/src/Elasticsearch/Endpoints/Suggest.php
@@ -38,10 +38,10 @@ class Suggest extends AbstractEndpoint
     public function getURI()
     {
         $index = $this->index;
-        $uri   = "/_suggest";
+        $uri   = "/_search";

         if (isset($index) === true) {
-            $uri = "/$index/_suggest";
+            $uri = "/$index/_search";
         }

         return $uri;

Fixed and tested OK in fork: https://github.com/finderly/elasticsearch-php/commit/8a52695712abef12cb5789aff28e310f03f59741

  • Operating System - centOs
  • PHP Version - 7.1
  • ES-PHP client version 6.0.1 / master
  • Elasticsearch version 6.1

tdashton avatar May 17 '18 11:05 tdashton

Ah, actually, we need to just delete that endpoint entirely. The suggest endpoint was removed from 6.x, the user should just use search.

I'll make that change in a bit, or if you want, happy to accept a PR :)

polyfractal avatar May 17 '18 16:05 polyfractal

Very true, as the differentiation / behavior is now implicit in the _search syntax, the extra one is no longer needed. I would be more than happy to make a PR, but I won't get to it until tomorrow morning MEST :)

tdashton avatar May 17 '18 16:05 tdashton

@polyfractal https://github.com/elastic/elasticsearch-php/pull/763

tdashton avatar May 18 '18 10:05 tdashton

The PR should be merged quickly. This API change is pretty confusing if you don't know about it, since the method isn't even marked deprecated.

gempir avatar Aug 30 '18 06:08 gempir

Solved in #763

ezimuel avatar Apr 23 '19 09:04 ezimuel