# ES 2.0 problem using PHP cURL commands

**URL:** <https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566>\
**Category:** Elasticsearch\
**Created:** [December 7, 2015, 6:29pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566 "2015-12-07T18:29:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyB](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@AndyB](https://discuss.elastic.co/u/AndyB)\
**Post date:** [December 7, 2015, 6:29pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566/1 "2015-12-07T18:29:48Z")

</div>

Hello, I have been able to use the following test script without any problems using ElasticSearch v1.x. But now that I have updated to ElasticSearch 2.1 it no longer works. I know the index is correct as I have another application that works fine, but this basic cURL is not.

```
<?php

$data_string = '{
"from" : 0, "size" : 100,
"sort" : [
    { "date" : {"order" : "desc"} }
],
"query": {
        "match" : {
            "thread.title" : {
                "query" : "pictures"
            }
        }
    }
}';

$ch = curl_init('http://localhost:9200/xenforo150/_search?pretty=true');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
'Content-Type: application/json',                                                                                
'Content-Length: ' . strlen($data_string))                                                                       
); 
 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

$result = curl_exec($ch);

echo $result;
```

---

<div class="post-metadata">

**Author:** ![AndyB](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@AndyB](https://discuss.elastic.co/u/AndyB)\
**Post date:** [December 7, 2015, 7:03pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566/2 "2015-12-07T19:03:08Z")

</div>

The output of $result is:

```
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : []
  }
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 7, 2015, 7:15pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566/3 "2015-12-07T19:15:25Z")

</div>

I can't really see what is wrong here...

Can you give what is the output of `GET xenforo150/_search`?

---

<div class="post-metadata">

**Author:** ![AndyB](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@AndyB](https://discuss.elastic.co/u/AndyB)\
**Post date:** [December 7, 2015, 7:28pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566/4 "2015-12-07T19:28:52Z")

</div>

The following command executed from the terminal works properly:

curl -XGET '[http://localhost:9200/xenforo150/\_search?q=title:pictures](http://localhost:9200/xenforo150/_search?q=title:pictures)'

I get the the data I'm expecting to get in post number 1.

---

<div class="post-metadata">

**Author:** ![AndyB](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@AndyB](https://discuss.elastic.co/u/AndyB)\
**Post date:** [December 7, 2015, 7:31pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566/5 "2015-12-07T19:31:44Z")

</div>

I changed the script by removing the thread.title to just title and now the script works.

---

<div class="post-metadata">

**Author:** ![AndyB](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@AndyB](https://discuss.elastic.co/u/AndyB)\
**Post date:** [December 7, 2015, 7:35pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566/6 "2015-12-07T19:35:05Z")

</div>

This is the mapping, why can't I use thread.title as I was able to with ElasticSearch v1.x.

```
[root@ss0084 ~]# curl -XGET 'http://localhost:9200/xenforo150/_mapping?pretty=true'
{
  "xenforo150" : {
    "mappings" : {
      "post" : {
        "properties" : {
          "date" : {
            "type" : "long"
          },
          "discussion_id" : {
            "type" : "long"
          },
          "message" : {
            "type" : "string"
          },
          "node" : {
            "type" : "long"
          },
          "thread" : {
            "type" : "long"
          },
          "title" : {
            "type" : "string"
          },
          "user" : {
            "type" : "long"
          }
        }
      },
      "thread" : {
        "properties" : {
          "date" : {
            "type" : "long"
          },
          "discussion_id" : {
            "type" : "long"
          },
          "message" : {
            "type" : "string"
          },
          "node" : {
            "type" : "long"
          },
          "thread" : {
            "type" : "long"
          },
          "title" : {
            "type" : "string"
          },
          "user" : {
            "type" : "long"
          }
        }
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 7, 2015, 7:53pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566/7 "2015-12-07T19:53:10Z")

</div>

Read this: [https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking\_20\_mapping\_changes.html#\_type\_name\_prefix\_removed](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_20_mapping_changes.html#_type_name_prefix_removed)

---

<div class="post-metadata">

**Author:** ![AndyB](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@AndyB](https://discuss.elastic.co/u/AndyB)\
**Post date:** [December 7, 2015, 8:09pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566/8 "2015-12-07T20:09:07Z")

</div>

Thank you, dadoonet.

---

<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 5, 2017, 11:32pm UTC](https://discuss.elastic.co/t/es-2-0-problem-using-php-curl-commands/36566/9 "2017-07-05T23:32:58Z")

</div>


