Help with PHP wrapper for _suggest query

I am using this simple constructor class for PHP calls to ES.

I am trying to add a stub for the following suggest query:

curl -XPOST 'localhost:9200/_suggest' -d '{
"my-suggestion" : {
"text" : "the amsterdma meetpu",
"term" : {
"field" : "body"
}
}
}'

Which is seen here:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters.html

What I get back is 404's from ES saying exists:"false"

Here is the code I am trying:

//curl -X GET http://localhost:9200/{INDEX}/{TYPE}/_suggest?q= ...
function suggest($type, $q, $size=5) {

    $suggestion = array('my-suggestion' => array('text' => $q,'term' =>array

('size' => $size, 'field' => 'title')));
return $this->call($type . '/_suggest?' . http_build_query(
$suggestion));

}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I don't believe the Suggest endpoint supports q parameters, you'll need
to send a request body instead. The best way to debug it is to print out
the URI and body before the curl request is network request is made, then
see if that runs as a curl command. Adjust as necessary to make the curl
work, then translate back to PHP.

Related, there is an official Elasticsearch-PHP client in case you didn't
know about it. The client supports the full
API: GitHub - elastic/elasticsearch-php: Official PHP client for Elasticsearch.

-Zach

On Monday, November 4, 2013 1:10:34 PM UTC-5, Kevin S wrote:

I am using this simple constructor class for PHP calls to ES.

https://github.com/hasantayyar/elasticsearch-php/blob/master/ElasticSearch.php

I am trying to add a stub for the following suggest query:

curl -XPOST 'localhost:9200/_suggest' -d '{
"my-suggestion" : {
"text" : "the amsterdma meetpu",
"term" : {
"field" : "body"
}
}
}'

Which is seen here:
Elasticsearch Platform — Find real-time answers at scale | Elastic

What I get back is 404's from ES saying exists:"false"

Here is the code I am trying:

//curl -X GET http://localhost:9200/{INDEX}/{TYPE}/_suggest?q= ...
function suggest($type, $q, $size=5) {

    $suggestion = array('my-suggestion' => array('text' => $q,'term' 

=> array('size' => $size, 'field' => 'title')));
return $this->call($type . '/_suggest?' . http_build_query(
$suggestion));

}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.