# Error for elasticsearch php api

**URL:** <https://discuss.elastic.co/t/error-for-elasticsearch-php-api/18368>\
**Category:** Elasticsearch\
**Created:** [June 27, 2014, 11:51am UTC](https://discuss.elastic.co/t/error-for-elasticsearch-php-api/18368 "2014-06-27T11:51:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Kruse\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stefan_kruse_2/32/12005_2.png) [@Stefan\_Kruse\_2](https://discuss.elastic.co/u/Stefan_Kruse_2)\
**Post date:** [June 27, 2014, 11:51am UTC](https://discuss.elastic.co/t/error-for-elasticsearch-php-api/18368/1 "2014-06-27T11:51:07Z")

</div>

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](mailto: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).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 30, 2014, 7:36am UTC](https://discuss.elastic.co/t/error-for-elasticsearch-php-api/18368/2 "2014-06-30T07:36:32Z")

</div>

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](mailto: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](mailto: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)  
> [https://groups.google.com/d/msgid/elasticsearch/0a4c6a94-939b-43b6-a2dd-5fa52172ea0a%40googlegroups.com?utm\_medium=email&utm\_source=footer](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](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](mailto: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](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](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tanguy\_Bernard](https://avatars.discourse-cdn.com/v4/letter/t/839c29/32.png) [@Tanguy\_Bernard](https://discuss.elastic.co/u/Tanguy_Bernard)\
**Post date:** [July 24, 2014, 10:12am UTC](https://discuss.elastic.co/t/error-for-elasticsearch-php-api/18368/3 "2014-07-24T10:12:14Z")

</div>

> 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](mailto: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](https://groups.google.com/d/msgid/elasticsearch/c322d0c5-1564-48eb-a307-b5fc6393723e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:13am UTC](https://discuss.elastic.co/t/error-for-elasticsearch-php-api/18368/4 "2017-07-06T01:13:33Z")

</div>


