Hi Effy,

>From how you describe the model you've created, I don't think it's
structured very well to help you perform the kind of queries you're looking
for.
It looks like you have a single tree with "products" as the root.  This
single tree structure means that there is no way to navigate between data
other than by going up and down the tree.  To find the data you're looking
for the query is having to visit every single node in the database - hence
the slow performance.

I recommend that you change the model so where you want to find products
that have similar attributes, you create nodes for the attribute values.
 For example, in your current model, two different phones made by Apple
with be stored as two nodes, each with a string property manufacturer =
"Apple".  Instead, I recommend creating a node that represents the
manufacturer Apple, and connecting the two phone nodes to the manufacturer
using a MANFUCTURED_BY relationship. In this model, finding other phones
from the same manufacturer is just a matter of traversing relationships,
rather than visiting every phone and testing the string value of its
manufacturer property.  This approach could be applied to all
the attributes where you there is a connection between different phones.
 For example, MobileOperatingSystem properties would be replaced by
relationships to nodes such as iOS and Android.  You should only be left
with properties that do not represent a connection between nodes, for
example model number.

In the case of battery capacity, you want to do range queries, and this is
slightly more complicated, because you want to find phones that have
"better" capacity, not exactly the same capacity.  This could be achieved
by creating a chain of capacity values, connected by
GREATER_THAN relationships.  Alternatively, you could index these fields
and find the set of capacity nodes from which to start your traversal.  See:
http://docs.neo4j.org/chunked/snapshot/indexing-lucene-extras.html#indexing-lucene-numeric-ranges

If I have time I will try to come up with some example Cypher queries for
model described here.

hope that helps,

-Alistair

On 14 November 2011 15:51, effy <e...@think-teva.com> wrote:

> Hi,
>
> I've trying to use Neo4j to simulate a graph database I need to create for
> a
> website I'm working on (currently running on SQL server).
> I created a bulk loading scripts and generated data (~100K nodes, ~120K
> properties, ~120K relationships, 2 relationship types).
> While running a simple traverse using Cypher, my query finishes in ~20
> seconds.
> I'm running my tests on webadmin, while the server (same computer) is
> running Windows 7, i7 920 (Quad Core) with 12GB RAM.
> Using neo4j latest community version (with default configuration, only
> enabled auto indexing for any case).
>
> If possible, I'd be glad if someone might show me what I'm doing wrong for
> getting these results...
>
> *This is how I built my nodes:*
>
> Product Details
>  - Properties: Name, Price
>
> Battery Details
> - Properties: MaH
> - Relationships: parent (Pointing to a Product Details node)
>
> Electronic Product Details
> - Properties: Voltage, Manufacturer
> - Relationships: parent (Pointing to a Product Details node)
>
> Mobile Phone
> - Properties: NetworkType, BluetoothEnabled, Color, MobileOperatingSystem
> - Relationships: parent (Pointing to a Electronic Product details node)
>
> For example, storing a mobile phone details in the database would have the
> following information stored:
> Battery:
> - Product Details (NodeID = 1): Name = Standard Battery, Manufacturer =
> Apple
> - Battery Details (NodeID = 2): MaH: 1600, Relationship: 'parent' pointing
> to NodeID = 1
>
> Mobile phone:
> - Product Details (NodeID = 3): Name = iPhone 3GS, Price = 300USD
> - Electronic Product Details (NodeID = 4): Manufacturer: Apple,
> Relationship: 'parent' pointing to NodeID = 3
> - Mobile Phone Details (NodeID = 5): NetworkType: GSM, Color: White,
> Relationship: 'parent' pointing to NodeID = 4, Relationship:
> 'BatteryProductNodeID' pointing to NodeID = 1
>
> I would like to allow browsing through all mobile phones (for instance) and
> show the users all of the allowed filter options (for example, show each
> possible Color and it's value).
> The Cypher query I've written for getting this data is (while also
> filtering
> the Battery MaH for example):
>
> start Products = node(1)
> match
>    Products<-[a:parent]-Product,
>    Product<-[b:parent]-ElectronicProduct,
>    ElectronicProduct<-[c:parent]-MobilePhone,
>    MobilePhone-[d:Battery]->Battery
> where Battery.MaH? > 1000
> return
>    MobilePhone.Color,
>    count(MobilePhone)
>
> Thanks for your help !
> Effy.
>
> --
> View this message in context:
> http://neo4j-community-discussions.438527.n3.nabble.com/Traversing-Performance-Slow-tp3507202p3507202.html
> Sent from the Neo4j Community Discussions mailing list archive at
> Nabble.com.
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to