Neo4j Granite Fields such as Solr

I use Neo4j in the ecommerce community built into PHP and using the REST interface.

I need to get all categories related to search results like Amazon. This feature is available on other systems such as Solr (another Lucene implementation) like Graphic Search.

How can I do a graphical search in Neo4j? or What is the best way (performance class) to recreate this feature?

All necessary modules associated with this function are excluded from the main neo4j package. I want to know if someone tries to do something like this without cross-cutting all the nodes in the graph, grab some properties and make groupCount from these values. If we have 200 thousand nodes, then the transverse value takes 10 seconds to get only the categories.

This is my Gremlin approach.

(new Neo4jVertexSequence( g.getRawGraph().index().forNodes('products').query( new org.neo4j.index.lucene.QueryContext('category:?') ), g ))._().groupBy{it.category}.cap.next(); 

Results in 90 lines and took 54 seconds.

 Books = 12002 Movies_Music_Games = 19233 Electronics_Computers = 60540 Home_Garden_Tools = 9123 Grocery_Health_Beauty = 15643 Toys_Kids_Baby = 15099 Clothing_Shoes_Jewelry = 12543 Sports_Outdoors = 10342 Automotive_Industrial = 9638 ... (more rows) 

Of course, I cannot put these results in the cache, because it is for a "non-interactive search." If the user makes a request like "Iphone", the request looks like

 (new Neo4jVertexSequence( g.getRawGraph().index().forNodes('products').query( new org.neo4j.index.lucene.QueryContext('search:"iphone" AND category:?') ), g ))._().groupBy{it.category}.cap.next(); 
+4
source share
1 answer

How about your domain model? Did you just put everything in the index? Usually you should model your categories as nodes and link your products to category nodes.

 (product)-[:HAS_CATEGORY]->(category)<-[:IS_CATEGORY]-(categories) 

In your query, you just go through this small tree and consider relationships like: HAS_CATEGORY, starting with each node category.

 start categories=node(x) match (product)-[:HAS_CATEGORY]->(category)<-[:IS_CATEGORY]-(categories) return category.name, count(*) 
0
source

Source: https://habr.com/ru/post/1441721/


All Articles