I am trying to index my mongodb collection using PlainElastic.Net client and also using CURL. But I am failing miserably in both the attempts.
My .net object is as follows
<BsonIgnoreExtraElements>
Public Class QueryReadyProduct
<BsonIgnore()>
<JsonIgnore()>
Property _id As Object
Property CustomerId As Guid
Property ProductId As Guid
Property CategoryId As Guid
Property CustomHierarchyId As Guid
<BsonRepresentation(BsonType.String)>
Property Name As String
End Class
When migrated to mongodb I get an additional _id
property field
With PlainElastic.net the following are the steps I am trying to execute
Dim data As String = "{
\"type\": \"mongodb\",
\"mongodb\": {
\"db\": \"brandviewdata\",
\"collection\": \"queryreadyproducts\"
},
\"index\": {
\"name\": \"mongoindex\",
\"type\": \"products\"
}
}"
Dim jsonData As String = serializer.ToJson(data)
Dim indexR As String = connection.Put(New IndexCommand("_river", "mongodb", "_meta"), "{}")
Dim mappingResult As String = connection.Put(New PutMappingCommand("_river", "mongodb"), jsonMapping)
Dim indexResult As String = connection.Put(New IndexCommand("_river", "mongodb", "_meta"), jsonData)
JSON Mapping is as follows
{
"queryreadyproduct": {
"type": "object",
"_all": {
"enabled": false
},
"dynamic": false,
"properties": {
"Name": {
"type": "string",
"analyzer": "standard"
},
"CustomerId": {
"type": "binary",
"index": "not_analyzed"
},
"ProductId": {
"type": "binary",
"index": "not_analyzed"
},
"CategoryId": {
"type": "binary",
"index": "not_analyzed"
},
"CustomHierarchyId": {
"type": "binary",
"null_value": "",
"index": "not_analyzed"
}
}
}
}
I keep getting the following error in ElasticSearch Log
[2013-06-07 10:42:21,763][DEBUG][action.index ] [Ranger] [_river][0], node[hKe8cliXSPmHcySUUmhJLg], [P], s[STARTED]: Failed to execute [index {[_river][mongodb][_meta], source["{ \"type\": \"mongodb\", \"mongodb\": { \"db\": \"brandviewdata\", \"collection\": \"queryreadyproducts\"}, \"index\": {\"name\": \"mongoindex\", \"type\": \"products\" }}\""]}]
org.elasticsearch.index.mapper.MapperParsingException: Malformed content, must start with an object
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:477)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:450)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:327)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:203)
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.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Also some times in the elastic search log
[2013-06-07 09:42:04,122][WARN ][river.routing ] [Ranger] no river type provided for [_river], ignoring...
I am really stuck at this point. Unable to find a solution. Any help to proceed further is appreciated.