elasticsearch-river-mongodb
elasticsearch-river-mongodb copied to clipboard
DBRefs as Object
Hi,
I update the river to 2.0.1 but DBRef still handle as string :(
Here my MongoDb collection
"users": [
{
"$ref": "users",
"$id": ObjectId("5437cbad03643f072c41f6b0")
}
]
Here how it's stored in ES
"users": [
"{ "$ref" : "users", "$id" : "5437cbad03643f072c41f6b0" }"
]
Could you help me?
Thank you
Do you want you DBRefs fetch or just to be Objects and not Strings?
If we wanted to fetch, then possibly we would want to change the implementation of convertDbRef to something like this:
private Map<String, Object> convertDbRef(DBRef ref) {
return createObjectMap(ref.fetch());
}
However, I'm not sure we always want to do this? I think we'd probably also want a flag controlling whether we fetch DBRefs.
DBRefs in general aren't really recommended. The MongoDB docs state:
Unless you have a compelling reason to use DBRefs, use manual references instead.
I agree with @benmccann we should keep string as default representation and maybe include a new flag to fetch the reference.
Ideally DBRefs should map to parent child mapping [1]
[1] - http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/parent-child-mapping.html
i've implemented this via https://github.com/richardwilly98/elasticsearch-river-mongodb/pull/525 Didn't use fetch though as its deprecated and doesn't always get you back a dbobject, working on adding a flag to toggle
flag is in