elasticsearch-river-mongodb icon indicating copy to clipboard operation
elasticsearch-river-mongodb copied to clipboard

DBRefs as Object

Open bmarguerite opened this issue 11 years ago • 4 comments

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

bmarguerite avatar Oct 23 '14 15:10 bmarguerite

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.

benmccann avatar Nov 08 '14 17:11 benmccann

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

richardwilly98 avatar Nov 09 '14 02:11 richardwilly98

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

mcleae avatar Apr 27 '15 14:04 mcleae

flag is in

mcleae avatar Apr 27 '15 15:04 mcleae