Error in indexing document in elasticsearch

When I try to index this document, I am getting an exception. stack trace is given below.

curl -XPOST localhost:9200/index1/talk?pretty=1 -d '

{

"_id" : ObjectId("503b29efe4b032e338f0581b"),

"_oid" : NumberLong(1182053),

"ns" : [

    {

        "n" : "Soldeu",

        "l" : "en",

        "t" : "p"

    }

]

}'

STACKTRACE :

org.elasticsearch.index.mapper.MapperParsingException: Failed to parse
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:509)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:438)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:287)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:210)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.elasticsearch.common.jackson.core.JsonParseException: Unexpected character ('O' (code 79)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: [B@5e7d093a; line: 4, column: 10]
at org.elasticsearch.common.jackson.core.JsonParser._constructError(JsonParser.java:1284)
at org.elasticsearch.common.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:588)
at org.elasticsearch.common.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:509)
at org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2094)
at org.elasticsearch.common.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:561)
at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:48)
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:461)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:494)
... 8 more

MAPPING:

curl -XPUT localhost:9200/index1?pretty=1 -d '{

    "mappings" : {

        "type1" : {

            "_all" : {"enabled" : false},

            "properties" : {

 "ns" : {

        "dynamic" : "true",

    		"properties" : {

	          "n" : {

	            "type" : "string"

	          },

	          "l" : {

	            "type" : "string"

	          },

		"t" : {

	            "type" : "string"

	          }

    }

  }

            }

        }

    }

}'

The problem seems to be in providing the mapping for ObjectId and NumberLong
ObjectId = org.bson.types.ObjectId and NumberLong = java.lang.Double

Can someone please help me in how to handle such fields with non-primitive datatypes

--

ObjectId and NumberLong are MongoDB concepts (IIRC). Simply map your
ObjectId as a string and NumberLong as a long.

--
Ivan

On Thu, Dec 20, 2012 at 10:03 PM, rahulg@travenues.com wrote:

ObjectId

--

Do I need to change these fields in MongoDB itself or just changing the ES
mapping should work.

I have tried changing my mapping to
curl -XPUT localhost:9200/index1?pretty=1 -d '{
"mappings": {
"type1": {
"_all": {
"enabled": false
},
"properties": {
"_id": {
"type": "string"
},
"_oid": {
"type": "long"
},
"ns": {
"dynamic": "true",
"properties": {
"n": {
"type": "string"
},
"l": {
"type": "string"
},
"t": {
"type": "string"
}
}
}
}
}
}
}'

but of no avail. I am still getting the same error for inserting the above
mentioned document.
On Friday, December 21, 2012 12:11:04 PM UTC+5:30, Ivan Brusic wrote:

ObjectId and NumberLong are MongoDB concepts (IIRC). Simply map your
ObjectId as a string and NumberLong as a long.

--
Ivan

On Thu, Dec 20, 2012 at 10:03 PM, <rah...@travenues.com <javascript:>>wrote:

ObjectId

--

The issue is not the mapping, but the document itself. Like I stated
before, ObjectId and NumberLong are MongoDB concepts. Those tags are not
standard JSON. The JSON parser will only accept standard JSON documents.
Not sure how you are integrating MongoDB with Elasticsearch. ObjectIds in
MongoDB contained specific information which is useless in Elasticsearch
(machine identifier, counter), so a pure String field would be a suitable
replacement. In fact, ids in ES should be strings.

NumberLong can just be a standard number field. I don't use JSON, but I
don't think JSON has number types. Anyone care to elaborate?

Cheers,

Ivan

On Thu, Dec 20, 2012 at 10:58 PM, rahulg@travenues.com wrote:

change these fields in MongoDB itself or just changing

--

Hi Rahul,

I am trying to index the documents in MognoDB using the mongo river. Were
you able to find any solution for this problem. Any help would be
appreciated.

Thanks,
Aditya

On Friday, December 21, 2012 6:58:39 AM UTC, Rahul Gupta wrote:

Do I need to change these fields in MongoDB itself or just changing the ES
mapping should work.

I have tried changing my mapping to
curl -XPUT localhost:9200/index1?pretty=1 -d '{
"mappings": {
"type1": {
"_all": {
"enabled": false
},
"properties": {
"_id": {
"type": "string"
},
"_oid": {
"type": "long"
},
"ns": {
"dynamic": "true",
"properties": {
"n": {
"type": "string"
},
"l": {
"type": "string"
},
"t": {
"type": "string"
}
}
}
}
}
}
}'

but of no avail. I am still getting the same error for inserting the above
mentioned document.
On Friday, December 21, 2012 12:11:04 PM UTC+5:30, Ivan Brusic wrote:

ObjectId and NumberLong are MongoDB concepts (IIRC). Simply map your
ObjectId as a string and NumberLong as a long.

--
Ivan

On Thu, Dec 20, 2012 at 10:03 PM, rah...@travenues.com wrote:

ObjectId

--
Brand View* *- Analyse the retail market, instantly

UK: 0844 357 9970
USA: 1-800-968-1876

Latest from the blog: New Out of Stock feature now available -

--
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.
For more options, visit https://groups.google.com/groups/opt_out.