Я пытаюсь проиндексировать свою коллекцию mongodb с помощью клиента PlainElastic.Net, а также с помощью CURL. Но я терплю неудачу в обеих попытках.
Мой объект .net выглядит следующим образом
<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
Конец класса
При переходе на mongodb я получаю дополнительное поле свойства _id
С PlainElastic.net я пытаюсь выполнить следующие шаги.
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 выглядит следующим образом
{
"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"
}
}
}
}
Я продолжаю получать следующую ошибку в журнале ElasticSearch
[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)
Также несколько раз в эластичном журнале поиска
[2013-06-07 09:42:04,122][WARN ][river.routing ] [Ranger] no river type provided for [_river], ignoring...
Я действительно застрял на этом этапе. Не удалось найти решение. Любая помощь для продолжения приветствуется.