# \[SOLVED\] Mistake input with Elastic PHP 8.5.0

**URL:** <https://discuss.elastic.co/t/solved-mistake-input-with-elastic-php-8-5-0/320182>\
**Category:** Elasticsearch\
**Created:** [November 30, 2022, 6:05pm UTC](https://discuss.elastic.co/t/solved-mistake-input-with-elastic-php-8-5-0/320182 "2022-11-30T18:05:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abkrim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abkrim/32/20217_2.png) [@abkrim](https://discuss.elastic.co/u/abkrim)\
**Post date:** [November 30, 2022, 6:05pm UTC](https://discuss.elastic.co/t/solved-mistake-input-with-elastic-php-8-5-0/320182/1 "2022-11-30T18:05:34Z")

</div>

I'm using PHP Client API for work with SQL (intensive)

But I've a problem.

In my first few unit tests, I was using a simple named index.

My surprise has been when trying to do the integration tests, when I took it out I already use aliases, like **testing-analyzers**

A query like this throws an exception

> SELECT vac1\_v,vac2\_v,vac\_v FROM test-analyzers WHERE id = 1 AND (vac1\_v \> 260 OR vac2\_v \> 260 OR vac3\_v \> 260)

```auto
$sql = ‘SELECT vac1_v,vac2_v,vac_v FROM test-analyzers WHERE id = 1 AND (vac1_v > 260 OR vac2_v > 260 OR vac3_v > 260)’

// Also try escaping the script -
// $sql = ‘SELECT vac1_v,vac2_v,vac_v FROM test\-analyzers WHERE id = 1 AND (vac1_v > 260 OR vac2_v > 260 OR vac3_v > 260)’

 $params = [
            'body' => [
                "query" => $sql
            ]
        ];

//params: [▼
// "body" => array:1 [▼
// "query" => "SELECT vac1_v,vac2_v,vac_v FROM test\-analyzers WHERE id = 1 AND //(vac1_v > 260 OR vac2_v > 260 OR vac3_v > 260)"
// ]

   $response = $client->sql()->query($params);

```

### Mistake

> 400 Bad Request: {"error":{"root\_cause":[{"type":"parsing\_exception","reason":"line 1:37: mismatched input '\' expecting {,

> "type":"parsing\_exception","reason":"line 1:37: mismatched input '-' expecting {,

Any ideas?

---

<div class="post-metadata">

**Author:** ![abkrim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abkrim/32/20217_2.png) [@abkrim](https://discuss.elastic.co/u/abkrim)\
**Post date:** [November 30, 2022, 6:29pm UTC](https://discuss.elastic.co/t/solved-mistake-input-with-elastic-php-8-5-0/320182/2 "2022-11-30T18:29:22Z")

</div>

I get a solution.

I need escape name of the index or alias with a hyphen _-_ between escaped "": Example below

> "query" =\> "SELECT log\_id,vac1\_v,vac2\_v,vac3\_v FROM "test-analyzers" WHERE log\_id = 1 AND (vac1\_v \> 260 OR vac2\_v \> 260 OR vac3\_v \> 260)"

After this working fine.

---

<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:** [December 28, 2022, 6:29pm UTC](https://discuss.elastic.co/t/solved-mistake-input-with-elastic-php-8-5-0/320182/3 "2022-12-28T18:29:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
