Skip to content

Latest commit

 

History

History
67 lines (54 loc) · 2.06 KB

README.org

File metadata and controls

67 lines (54 loc) · 2.06 KB

GraphRek

Content

Introduction

This is a demo how to use Graphdb Neo4j for a recommendation system. In this demo, there will be post with labels to be created and stored as a graph database. Then we can use Cyper to query posts with related labels.

Setting up

$ docker-compose up -d
$ pipenv install --dev
$ pipenv run dev

How to use

  1. Neo4j Database Web Client can be accessed at localhost:7474

This web-based client provides visual details and Cyper CLI to interact with the current Database. To connect:

  • Type in the commandline located at the top of the Web-Client
:server connect
  • Change the Connect URL to bolt://neo4j:test@localhost:7687 (as set in config.ini)
  • Authenticate with USERNAME / PASSWORD using:
USER: neo4j
PWD: test
  1. Running Fastapi Application, go to localhost:8000/docs for api usage:
  • Create labels: PUT -> /thing/create-labels

    Create some distinct labels first, eg: food, travel, blog, technology, music etc

  • Create posts: PUT -> /thing/create-posts?label=some-label

    Create some posts for a specific label. A single post can use multiple labels (M2M model)

Post data required:

{
  "id": "some-random-id",
  "score": 1999 # score of the post
}
  • Query posts by specific labels: GET -> /thing/get-posts?label=some-label

Calling this api will query posts that are labelled with the specified labels, order by the posts’ scores. At the same time, it will return some more recommended posts with indirect relation to the queried labels.

The relationship can be seen as: (Ref. to conn/neo4j.py)

(specified_label)<--(direct_related_post)-->(random_label)<--(recommended_posts)-//->(specified_label)