Error for elasticsearch php api

Hi, i try to use the es php module. I can indexing documents but when i
search for something i got an error and dont know what this mean. I use
this script:

<?php require '../vendor/autoload.php'; $client = new Elasticsearch\Client(); $params = array(); $params['body'] = array('testField' => 'abc'); $params['index'] = 'my_index'; $params['type'] = 'my_type'; $params['id'] = 'my_id'; // Document will be indexed to my_index/my_type/my_id $ret = $client->index($params); /** * SEARCH **/ $params['index'] = 'my_index'; $params['type'] = 'my_type'; $results = $client->search($params); ?>

AND THE ERROR MESSAGE IS:

Fatal error: Uncaught exception
'Elasticsearch\Common\Exceptions\UnexpectedValueException' with message 'id
is not a valid parameter' in
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php:263
Stack trace: #0
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php(239):
Elasticsearch\Endpoints\AbstractEndpoint->ifParamsInvalidThrowException(Array)
#1
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php(115):
Elasticsearch\Endpoints\AbstractEndpoint->checkUserParams(Array) #2
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php(1009):
Elasticsearch\Endpoints\AbstractEndpoint->setParams(Array) #3
/var/www/awesome/index.php(23): Elasticsearch\Client->search(Array) #4
{main} thrown in
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php
on line

263Maybe someone knows what this could be. Thanks a lot for helping.
Stefan

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0a4c6a94-939b-43b6-a2dd-5fa52172ea0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hey,

my PHP skills are next to none, but if you dont clear out that params
array, dont you try to execute the search operation with exactly the same
as the index operation (which will very likely fail, as id is not a valid
parameter for a search, as mentioned in the error message)?

--Alex

On Fri, Jun 27, 2014 at 1:51 PM, Stefan Kruse besucher80@gmx.de wrote:

Hi, i try to use the es php module. I can indexing documents but when i
search for something i got an error and dont know what this mean. I use
this script:

<?php require '../vendor/autoload.php'; $client = new Elasticsearch\Client(); $params = array(); $params['body'] = array('testField' => 'abc'); $params['index'] = 'my_index'; $params['type'] = 'my_type'; $params['id'] = 'my_id'; // Document will be indexed to my_index/my_type/my_id $ret = $client->index($params); /** * SEARCH **/ $params['index'] = 'my_index'; $params['type'] = 'my_type'; $results = $client->search($params); ?>

AND THE ERROR MESSAGE IS:

Fatal error: Uncaught exception
'Elasticsearch\Common\Exceptions\UnexpectedValueException' with message 'id
is not a valid parameter' in
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php:263
Stack trace: #0
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php(239):
Elasticsearch\Endpoints\AbstractEndpoint->ifParamsInvalidThrowException(Array)
#1
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php(115):
Elasticsearch\Endpoints\AbstractEndpoint->checkUserParams(Array) #2
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Client.php(1009):
Elasticsearch\Endpoints\AbstractEndpoint->setParams(Array) #3
/var/www/awesome/index.php(23): Elasticsearch\Client->search(Array) #4
{main} thrown in
/var/www/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Endpoints/AbstractEndpoint.php
on line

263Maybe someone knows what this could be. Thanks a lot for helping.
Stefan

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/0a4c6a94-939b-43b6-a2dd-5fa52172ea0a%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/0a4c6a94-939b-43b6-a2dd-5fa52172ea0a%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM8X1fdK1ZMaJuG8MNkA%2B0%2BMLKTQiboVGVbv9TRTP_iN%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

My answer is very late, but here :

<?php > > require '../vendor/autoload.php'; > > $client = new Elasticsearch\Client(); > > $params = array(); > $params['body'] = array('testField' => 'abc'); > > $params['index'] = 'my_index'; > $params['type'] = 'my_type'; > $params['id'] = 'my_id'; > > // Document will be indexed to my_index/my_type/my_id > $ret = $client->index($params); > > /** > * SEARCH > **/ > $params['index'] = 'my_index'; > $params['type'] = 'my_type'; > > *//HERE your params =

array('index'=>my_index,'type'=>'my_type',body=>array(test=>abc)) *

  •      //Your body is incorrect for search*
    
  •     //I suggest this if you want find result of a specific id :*
    
  •      $params=array(); //reset first*
    
  •      $params = **array(*
    
  •                    'index' => 'my_index',*
    
  •                    'type'=>'my_type',*
    
  •                    "body"=>array(*
    
  •                        'query'=> array(*
    
  •                            "match" =>array( *
    
  •                                "_id"=> 'my_id',*
    
  •                            )*
    
  •                        )*
    
  •                    ),*
    
  •                );*
    

    $results = $client->search($params);

?>

Tanguy

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c322d0c5-1564-48eb-a307-b5fc6393723e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.