WinXP file_get_contents with PUT don't work

I'm trying to setup ES in WinXP box using the PHP class from here
http://hublog.hubmed.org/archives/001907.html

For all the method with GET (query , check status, etc) it worked but
when using PUT (creating index) it produced the following error

===========================
http://localhost:9200/putusan/array(1) { ["method"]=> string(3)
"PUT" }
A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://localhost:9200/putusan/)
[function.file-get-contents]: failed to open stream: HTTP request
failed! HTTP/1.0 400 Bad Request

Filename: libraries/Elasticsearch.php

Line Number: 15

What I don't understand is how come the get method worked but not with
the PUT method
I've also tried installing curl and run it in command prompt and I got
the same result
the GET method for Status and Query worked, but not with the PUT.

Is this something with the ES or just with the PHP or CURL issue?

Anyone can shed some light about this?

Also in the log I found this

[20:39:07,750][DEBUG][action.index ] [van Lunt, Cornelius]
[putusan][3], Node[6202ffed-7ae8-4ad3-85b2-6ccd3c126925], [P],
S[STARTED]: Failed to execute [[putusan][ma][1],
source['{keyword:data}']]
org.elasticsearch.index.mapper.MapperParsingException: Failed to parse
at
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
333)
at
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
272)
at
org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:
236)
at
org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:
228)
at
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
125)
at
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
56)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:
328)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.access
$400(TransportShardReplicationOperationAction.java:198)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction
$1.run(TransportShardReplicationOperationAction.java:252)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.elasticsearch.util.jackson.JsonParseException:
Unexpected character (''' (code 39)): expected a valid value (number,
String, array, object, 'true', 'false' or 'null')
at [Source: [B@b206e9; line: 1, column: 2]
at
org.elasticsearch.util.jackson.JsonParser._constructError(JsonParser.java:
943)
at
org.elasticsearch.util.jackson.impl.JsonParserBase._reportError(JsonParserBase.java:
632)
at
org.elasticsearch.util.jackson.impl.JsonParserBase._reportUnexpectedChar(JsonParserBase.java:
565)
at
org.elasticsearch.util.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:
1077)
at
org.elasticsearch.util.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:
212)
at
org.elasticsearch.util.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:
46)
at
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
289)
... 11 more

On Jul 6, 9:09 pm, Chenri chenrij...@gmail.com wrote:

I'm trying to setup ES in WinXP box using the PHP class from herehttp://hublog.hubmed.org/archives/001907.html

For all the method with GET (query , check status, etc) it worked but
when using PUT (creating index) it produced the following error

===========================http://localhost:9200/putusan/array(1) { ["method"]=> string(3)
"PUT" }
A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://localhost:9200/putusan/)
[function.file-get-contents]: failed to open stream: HTTP request
failed! HTTP/1.0 400 Bad Request

Filename: libraries/Elasticsearch.php

Line Number: 15

What I don't understand is how come the get method worked but not with
the PUT method
I've also tried installing curl and run it in command prompt and I got
the same result
the GET method for Status and Query worked, but not with the PUT.

Is this something with the ES or just with the PHP or CURL issue?

Anyone can shed some light about this?

Can you provide the actual PUT request that you used?

It is likely that the syntax is wrong.

ta

clint

On Tue, 2010-07-06 at 07:14 -0700, Chenri wrote:

Also in the log I found this

[20:39:07,750][DEBUG][action.index ] [van Lunt, Cornelius]
[putusan][3], Node[6202ffed-7ae8-4ad3-85b2-6ccd3c126925], [P],
S[STARTED]: Failed to execute [[putusan][ma][1],
source['{keyword:data}']]
org.elasticsearch.index.mapper.MapperParsingException: Failed to parse
at
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
333)
at
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
272)
at
org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:
236)
at
org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:
228)
at
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
125)
at
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:
56)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:
328)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction.access
$400(TransportShardReplicationOperationAction.java:198)
at
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
$AsyncShardOperationAction
$1.run(TransportShardReplicationOperationAction.java:252)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.elasticsearch.util.jackson.JsonParseException:
Unexpected character (''' (code 39)): expected a valid value (number,
String, array, object, 'true', 'false' or 'null')
at [Source: [B@b206e9; line: 1, column: 2]
at
org.elasticsearch.util.jackson.JsonParser._constructError(JsonParser.java:
943)
at
org.elasticsearch.util.jackson.impl.JsonParserBase._reportError(JsonParserBase.java:
632)
at
org.elasticsearch.util.jackson.impl.JsonParserBase._reportUnexpectedChar(JsonParserBase.java:
565)
at
org.elasticsearch.util.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:
1077)
at
org.elasticsearch.util.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:
212)
at
org.elasticsearch.util.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:
46)
at
org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:
289)
... 11 more

On Jul 6, 9:09 pm, Chenri chenrij...@gmail.com wrote:

I'm trying to setup ES in WinXP box using the PHP class from herehttp://hublog.hubmed.org/archives/001907.html

For all the method with GET (query , check status, etc) it worked but
when using PUT (creating index) it produced the following error

===========================http://localhost:9200/putusan/array(1) { ["method"]=> string(3)
"PUT" }
A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://localhost:9200/putusan/)
[function.file-get-contents]: failed to open stream: HTTP request
failed! HTTP/1.0 400 Bad Request

Filename: libraries/Elasticsearch.php

Line Number: 15

What I don't understand is how come the get method worked but not with
the PUT method
I've also tried installing curl and run it in command prompt and I got
the same result
the GET method for Status and Query worked, but not with the PUT.

Is this something with the ES or just with the PHP or CURL issue?

Anyone can shed some light about this?
--
Web Announcements Limited is a company registered in England and Wales,
with company number 05608868, with registered address at 10 Arvon Road,
London, N5 1PR.

$data='{"keyword":"halo"}';
$elasticsearch->add($id,$data);

below are the format echoed from the php ES class code

file_get_contents(
http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b, NULL,
stream_context_create(array('http' => Array))))

where the *Array *contains
array(2) { ["method"]=> string(3) "PUT" ["content"]=> string(18)
"{"keyword":"halo"}" }

On Tue, Jul 6, 2010 at 9:16 PM, Clinton Gormley clinton@iannounce.co.ukwrote:

Can you provide the actual PUT request that you used?

It is likely that the syntax is wrong.

ta

clint

On Tue, 2010-07-06 at 07:14 -0700, Chenri wrote:

Also in the log I found this

[20:39:07,750][DEBUG][action.index ] [van Lunt, Cornelius]
[putusan][3], Node[6202ffed-7ae8-4ad3-85b2-6ccd3c126925], [P],
S[STARTED]: Failed to execute [[putusan][ma][1],
source['{keyword:data}']]
org.elasticsearch.index.mapper.MapperParsingException: Failed to parse
at

org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:

  1. at

org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:

  1. at

org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:

  1. at

org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:

  1. at

org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:

  1. at

org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:

  1. at

org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction

$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:

  1. at

org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction

$AsyncShardOperationAction.access
$400(TransportShardReplicationOperationAction.java:198)
at

org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction

$AsyncShardOperationAction
$1.run(TransportShardReplicationOperationAction.java:252)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.elasticsearch.util.jackson.JsonParseException:
Unexpected character (''' (code 39)): expected a valid value (number,
String, array, object, 'true', 'false' or 'null')
at [Source: [B@b206e9; line: 1, column: 2]
at

org.elasticsearch.util.jackson.JsonParser._constructError(JsonParser.java:

  1. at

org.elasticsearch.util.jackson.impl.JsonParserBase._reportError(JsonParserBase.java:

  1. at

org.elasticsearch.util.jackson.impl.JsonParserBase._reportUnexpectedChar(JsonParserBase.java:

  1. at

org.elasticsearch.util.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:

  1. at

org.elasticsearch.util.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:

  1. at

org.elasticsearch.util.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:

  1. at

org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:

  1. ... 11 more

On Jul 6, 9:09 pm, Chenri chenrij...@gmail.com wrote:

I'm trying to setup ES in WinXP box using the PHP class from
herehttp://hublog.hubmed.org/archives/001907.html

For all the method with GET (query , check status, etc) it worked but
when using PUT (creating index) it produced the following error

===========================http://localhost:9200/putusan/array(1) {
["method"]=> string(3)
"PUT" }
A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://localhost:9200/putusan/)
[function.file-get-contents]: failed to open stream: HTTP request
failed! HTTP/1.0 400 Bad Request

Filename: libraries/Elasticsearch.php

Line Number: 15

What I don't understand is how come the get method worked but not with
the PUT method
I've also tried installing curl and run it in command prompt and I got
the same result
the GET method for Status and Query worked, but not with the PUT.

Is this something with the ES or just with the PHP or CURL issue?

Anyone can shed some light about this?
--
Web Announcements Limited is a company registered in England and Wales,
with company number 05608868, with registered address at 10 Arvon Road,
London, N5 1PR.

--
Chenri J
Mutiara Taman Palem H2-3
Mobile Phone: (62) (813) 152 05 949

I've also tried to changed the
$data ="halo";

this also create the same error

On Tue, Jul 6, 2010 at 9:39 PM, Chenri chenrijano@gmail.com wrote:

$data='{"keyword":"halo"}';
$elasticsearch->add($id,$data);

below are the format echoed from the php ES class code

file_get_contents(
http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b, NULL,
stream_context_create(array('http' => Array))))

where the *Array *contains
array(2) { ["method"]=> string(3) "PUT" ["content"]=> string(18)
"{"keyword":"halo"}" }

On Tue, Jul 6, 2010 at 9:16 PM, Clinton Gormley clinton@iannounce.co.ukwrote:

Can you provide the actual PUT request that you used?

It is likely that the syntax is wrong.

ta

clint

On Tue, 2010-07-06 at 07:14 -0700, Chenri wrote:

Also in the log I found this

[20:39:07,750][DEBUG][action.index ] [van Lunt, Cornelius]
[putusan][3], Node[6202ffed-7ae8-4ad3-85b2-6ccd3c126925], [P],
S[STARTED]: Failed to execute [[putusan][ma][1],
source['{keyword:data}']]
org.elasticsearch.index.mapper.MapperParsingException: Failed to parse
at

org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:

  1. at

org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:

  1. at

org.elasticsearch.index.shard.service.InternalIndexShard.innerIndex(InternalIndexShard.java:

  1. at

org.elasticsearch.index.shard.service.InternalIndexShard.index(InternalIndexShard.java:

  1. at

org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:

  1. at

org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:

  1. at

org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction

$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:

  1. at

org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction

$AsyncShardOperationAction.access
$400(TransportShardReplicationOperationAction.java:198)
at

org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction

$AsyncShardOperationAction
$1.run(TransportShardReplicationOperationAction.java:252)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.elasticsearch.util.jackson.JsonParseException:
Unexpected character (''' (code 39)): expected a valid value (number,
String, array, object, 'true', 'false' or 'null')
at [Source: [B@b206e9; line: 1, column: 2]
at

org.elasticsearch.util.jackson.JsonParser._constructError(JsonParser.java:

  1. at

org.elasticsearch.util.jackson.impl.JsonParserBase._reportError(JsonParserBase.java:

  1. at

org.elasticsearch.util.jackson.impl.JsonParserBase._reportUnexpectedChar(JsonParserBase.java:

  1. at

org.elasticsearch.util.jackson.impl.Utf8StreamParser._handleUnexpectedValue(Utf8StreamParser.java:

  1. at

org.elasticsearch.util.jackson.impl.Utf8StreamParser.nextToken(Utf8StreamParser.java:

  1. at

org.elasticsearch.util.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:

  1. at

org.elasticsearch.index.mapper.xcontent.XContentDocumentMapper.parse(XContentDocumentMapper.java:

  1. ... 11 more

On Jul 6, 9:09 pm, Chenri chenrij...@gmail.com wrote:

I'm trying to setup ES in WinXP box using the PHP class from
herehttp://hublog.hubmed.org/archives/001907.html

For all the method with GET (query , check status, etc) it worked but
when using PUT (creating index) it produced the following error

===========================http://localhost:9200/putusan/array(1) {
["method"]=> string(3)
"PUT" }
A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://localhost:9200/putusan/)
[function.file-get-contents]: failed to open stream: HTTP request
failed! HTTP/1.0 400 Bad Request

Filename: libraries/Elasticsearch.php

Line Number: 15

What I don't understand is how come the get method worked but not with
the PUT method
I've also tried installing curl and run it in command prompt and I got
the same result
the GET method for Status and Query worked, but not with the PUT.

Is this something with the ES or just with the PHP or CURL issue?

Anyone can shed some light about this?
--
Web Announcements Limited is a company registered in England and Wales,
with company number 05608868, with registered address at 10 Arvon Road,
London, N5 1PR.

--
Chenri J
Mutiara Taman Palem H2-3
Mobile Phone: (62) (813) 152 05 949
NOTsolution.com

--
Chenri J
Mutiara Taman Palem H2-3
Mobile Phone: (62) (813) 152 05 949

On Tue, Jul 6, 2010 at 9:39 PM, Chenri chenrijano@gmail.com wrote:
$data='{"keyword":"halo"}';
$elasticsearch->add($id,$data);

    below are the format echoed from  the php ES class code 
    file_get_contents(http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b, NULL, stream_context_create(array('http' => Array))))
    
    
    where the Array contains
    array(2) { ["method"]=> string(3) "PUT" ["content"]=>
    string(18) "{"keyword":"halo"}" }

The equivalent using curl on the command line (at least in Unix - can't
speak for Windows) would be:

curl -XPUT 'http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b' -d '
{
"keywords" : "halo"
}
'

Does that work?

Looking at your error message:

            > Caused by:
            org.elasticsearch.util.jackson.JsonParseException:
            > Unexpected character (''' (code 39)): expected a
            valid value (number,
            > String, array, object, 'true', 'false' or 'null')
            >  at [Source: [B@b206e9; line: 1, column: 2]
            >       at
            >

your JSON is malformed.

clint

After trying to port the class using curl in PHP
and succeed in several method but failure in others
I've decided that I'll go for the linux environment.

Anyway thanks for the help Clint

On Tue, Jul 6, 2010 at 9:53 PM, Clinton Gormley clinton@iannounce.co.ukwrote:

On Tue, Jul 6, 2010 at 9:39 PM, Chenri chenrijano@gmail.com wrote:
$data='{"keyword":"halo"}';
$elasticsearch->add($id,$data);

    below are the format echoed from  the php ES class code
    file_get_contents(

http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b, NULL,
stream_context_create(array('http' => Array))))

    where the Array contains
    array(2) { ["method"]=> string(3) "PUT" ["content"]=>
    string(18) "{"keyword":"halo"}" }

The equivalent using curl on the command line (at least in Unix - can't
speak for Windows) would be:

curl -XPUT '
http://localhost:9200/putusan/ma/8b076cb020b8bf19bc4aab8583bb080b' -d '
{
"keywords" : "halo"
}
'

Does that work?

Looking at your error message:

            > Caused by:
            org.elasticsearch.util.jackson.JsonParseException:
            > Unexpected character (''' (code 39)): expected a
            valid value (number,
            > String, array, object, 'true', 'false' or 'null')
            >  at [Source: [B@b206e9; line: 1, column: 2]
            >       at
            >

your JSON is malformed.

clint

--
Chenri J
Mutiara Taman Palem H2-3
Mobile Phone: (62) (813) 152 05 949