Question

I'm trying to figure out how to model this scenario in Neo4j.

I have a "product" node with a name attribute. The problem is that the name attribute can several variations across different languages which should all reference the same node.

I want to be able to search across the name and all of its variations to reference the one node.

.eg.

Name: Banana
Variation: Banano
Variation: Banane

etc.

Nodes:

Food {id: 1, name: "Banana"}

Translation {id: 1000, name: "Banane", language: "French"}

Relationship

(:Food)<-[:SIMILAR_TO]-(:translation)

I'm looking some more efficient that will easily work with an index for fast search.

Any suggestions on how to best model this scenario ?

Was it helpful?

Solution

Here is an example of what you can do:

(:Product {id: 1})-[:HAS_NAME]->(:Name {name:"Banana", lang:"en"})
         "        -[:HAS_NAME]->(:Name {name:"Banane", lang:"fr"})
         "        -[:HAS_NAME]->(:Name {name:"Banano", lang:"it"})

(:Product {id: 1})-[:SIMILAR_TO]->(:Food)

You can create a uniqueness constraint on :Product id, and an index on :Name name.

This way, you can easily find all the localized names for a specific product, and easily find all the products that have a specific name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top