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

[FEATURE]: Support Map types #9146

Open
RJKeevil opened this issue Aug 26, 2024 · 2 comments
Open

[FEATURE]: Support Map types #9146

RJKeevil opened this issue Aug 26, 2024 · 2 comments
Labels
kind/feature Something completely new we should consider.

Comments

@RJKeevil
Copy link
Contributor

RJKeevil commented Aug 26, 2024

Use case

We have a number of use cases where having a map type predicate would simplify our usage of dgraph. A good example is real-world address node, which may have multiple known address strings that refer to that address (e.g. ["32 Heren Gracht, Amsterdam, 1015BA","32, Herengracht, Amsterdam, 1015BA, NL"]). We run the addresses through a parser to extract known features such as number, postcode, country etc. Storing these as separate properties is problematic as it loses the lineage/grouping (which house number goes with which postcode etc in the raw data). A map (or preferably, a set of maps) would allow such nested/grouped structures.

I know this could instead be modelled as child nodes, but that a) makes our logic much more complex, and b) doesnt model the data in a way suitable for client usage patterns. So for now we marshall maps backwards and forwards from strings to achieve this.

Links to Discuss, RFC or previous Issues and PRs

No response

Links to examples and research

https://docs.arcadedb.com/#DataTypes
https://neo4j.com/docs/cypher-manual/current/values-and-types/maps/

Current state

As mentioned, can marshal to or from strings, or use child nodes, but both are suboptimal via perfomance overhead and query complexity

Solution proposal

Main complexity would be this will need a mechanism to query fields within maps. Perhaps libraries like https://github.com/elgs/jsonql can be of inspiration for what functionality may be of use here. For MVP just having a map object that i interact with client side would be already a big help.

Additional Information

No response

@RJKeevil RJKeevil added the kind/feature Something completely new we should consider. label Aug 26, 2024
@dgraph-io dgraph-io deleted a comment Aug 26, 2024
@harshil-goel
Copy link
Contributor

Can you try storing the map as a list of bytes using default directive? Or just by using jq urself to store it as a string?

@RJKeevil
Copy link
Contributor Author

Yes, that is essentially what I do. It works ok, but having true map support would be a good feature I think, especially if i could subquery them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Something completely new we should consider.
Development

No branches or pull requests

2 participants