Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBRefs as Object #350

Open
bmarguerite opened this issue Oct 23, 2014 · 4 comments
Open

DBRefs as Object #350

bmarguerite opened this issue Oct 23, 2014 · 4 comments

Comments

@bmarguerite
Copy link

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

@benmccann
Copy link
Collaborator

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.

@richardwilly98
Copy link
Owner

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

@mcleae
Copy link

mcleae commented Apr 27, 2015

i've implemented this via #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
Copy link

mcleae commented Apr 27, 2015

flag is in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants