{"id":21273533,"url":"https://github.com/graphaware/graph-aided-search-demo","last_synced_at":"2026-01-02T16:39:50.696Z","repository":{"id":42408601,"uuid":"55500141","full_name":"graphaware/graph-aided-search-demo","owner":"graphaware","description":null,"archived":false,"fork":false,"pushed_at":"2018-02-01T12:15:52.000Z","size":17156,"stargazers_count":21,"open_issues_count":2,"forks_count":9,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-01-22T03:09:54.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphaware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-05T10:49:48.000Z","updated_at":"2022-05-20T09:50:04.000Z","dependencies_parsed_at":"2022-09-01T01:01:25.790Z","dependency_job_id":null,"html_url":"https://github.com/graphaware/graph-aided-search-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fgraph-aided-search-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fgraph-aided-search-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fgraph-aided-search-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphaware%2Fgraph-aided-search-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphaware","download_url":"https://codeload.github.com/graphaware/graph-aided-search-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732252,"owners_count":20338831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T09:15:21.462Z","updated_at":"2026-01-02T16:39:50.655Z","avatar_url":"https://github.com/graphaware.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphAware GraphAidedSearch Demo\n\nDocker Compose setup for testing `Graph-Aided Search` combining Elasticsearch and Neo4j.\n\nThe following will be run and configured automatically :\n\n* Elasticsearch 2.2.2 listening on port 9200 and the `Graph-Aided Search` plugin installed\n* Neo4j 2.3.3 listening on port 7474\n* GraphAware [neo4j-framework](https://github.com/graphaware/neo4j-framework) and GraphAware [neo4j-to-elasticsearch](https://github.com/graphaware/neo4j-to-elasticsearch) plugin installed and configured\n* CSV sources for running the examples installed in the `data/import` directory of Neo4j and the server is\nconfigured to allow loading external files from this path\n* A `_query` directory providing json files of all the queries from the demo\n\n### Setup\n\n```bash\n# Create a network bridge\ndocker network create --driver bridge gas\n\n# Export the network name \"gas\" as environment variable\n# bash\nexport NETWORK=gas\n#fish-shell\nset -x NETWORK \"gas\"\n\n# Run the stack with Docker Compose\ndocker-compose up\n\n# wait neo4j and elasticsearch are initialized\nStarting neo4j\nStarting elastic_container\nAttaching to neo4j, elastic_container\nneo4j             | Starting Neo4j Server console-mode...\nelastic_container | [2016-04-08 00:52:47,608][INFO ][node                     ] [James \"Jimmy\" Marks] version[2.2.2], pid[1], build[fcc01dd/2016-03-29T08:49:35Z]\nelastic_container | [2016-04-08 00:52:47,631][INFO ][node                     ] [James \"Jimmy\" Marks] initializing ...\nneo4j             | 2016-04-08 00:52:49.566+0000 INFO  Initiating metrics..\nelastic_container | [2016-04-08 00:52:50,388][INFO ][plugins                  ] [James \"Jimmy\" Marks] modules [lang-expression, lang-groovy], plugins [graph-aided-search], sites []\nelastic_container | [2016-04-08 00:52:50,422][INFO ][env                      ] [James \"Jimmy\" Marks] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda1)]], net usable_space [182.6gb], net total_space [195.8gb], spins? [possibly], types [ext4]\nelastic_container | [2016-04-08 00:52:50,427][INFO ][env                      ] [James \"Jimmy\" Marks] heap size [1015.6mb], compressed ordinary object pointers [true]\nelastic_container | [2016-04-08 00:52:57,040][INFO ][node                     ] [James \"Jimmy\" Marks] initialized\nelastic_container | [2016-04-08 00:52:57,044][INFO ][node                     ] [James \"Jimmy\" Marks] starting ...\nelastic_container | [2016-04-08 00:52:57,479][INFO ][transport                ] [James \"Jimmy\" Marks] publish_address {172.18.0.3:9300}, bound_addresses {[::]:9300}\nelastic_container | [2016-04-08 00:52:57,513][INFO ][discovery                ] [James \"Jimmy\" Marks] docker/MandNLv-RHekkkaZajymKQ\nneo4j             | 2016-04-08 00:52:58.383+0000 INFO  Successfully started database\nneo4j             | 2016-04-08 00:52:58.420+0000 INFO  Starting HTTP on port 7474 (1 threads available)\nneo4j             | 2016-04-08 00:52:58.723+0000 INFO  Enabling HTTPS on port 7473\nneo4j             | 2016-04-08 00:52:58.728+0000 INFO  Mounted REST API at: /db/manage\nneo4j             | 2016-04-08 00:52:58.742+0000 INFO  Mounted unmanaged extension [com.graphaware.server] at [/graphaware]\nneo4j             | 2016-04-08 00:52:58.852+0000 INFO  Mounting static content at /webadmin\nneo4j             | 2016-04-08 00:52:58.937+0000 INFO  Mounting static content at /browser\nelastic_container | [2016-04-08 00:53:00,619][INFO ][cluster.service          ] [James \"Jimmy\" Marks] new_master {James \"Jimmy\" Marks}{MandNLv-RHekkkaZajymKQ}{172.18.0.3}{172.18.0.3:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)\nelastic_container | [2016-04-08 00:53:00,690][INFO ][http                     ] [James \"Jimmy\" Marks] publish_address {172.18.0.3:9200}, bound_addresses {[::]:9200}\nelastic_container | [2016-04-08 00:53:00,699][INFO ][node                     ] [James \"Jimmy\" Marks] started\nelastic_container | [2016-04-08 00:53:00,770][INFO ][gateway                  ] [James \"Jimmy\" Marks] recovered [0] indices into cluster_state\nneo4j             | 2016-04-08 00:53:04.976+0000 INFO  Remote interface ready and available at http://0.0.0.0:7474/\n```\n\nNeo4j will be available on your docker host ip (generally `localhost` on Linux and `192.168.99.100` on OS X) on port 7474 and Elasticsearch on port 9200.\n\n#### Configure the plugin settings\n\n```bash\ncurl -XPUT 'http://localhost:9200/neo4j-index/' -d '{\n    \"settings\" : {\n        \"index.gas.neo4j.hostname\" : \"http://localhost:7474\",\n        \"index.gas.enable\" : true\n    }\n}'\n```\n\n```bash\nikwattro@graphaware ~\u003e  curl -XPUT 'http://localhost:9200/neo4j-index/' -d '{\n\u003e     \"settings\" : {\n\u003e         \"index.gas.neo4j.hostname\" : \"http://localhost:7474\",\n\u003e         \"index.gas.enable\" : true\n\u003e     }\n\u003e }'\n{\"acknowledged\":true}                                                                                                                                                                           ikwattro@graphaware ~\u003e\n```\n\n#### Add the schema constraints in Neo4j\n\nOpen up the browser and run these 2 cypher statements :\n\n```bash\nCREATE CONSTRAINT ON (n:Movie) ASSERT n.objectId IS UNIQUE;\n\nCREATE CONSTRAINT ON (n:User) ASSERT n.objectId IS UNIQUE;\n```\n\nCreate the Users from the CSV dataset :\n\n```bash\nUSING PERIODIC COMMIT 500\nLOAD CSV FROM \"file:///u.user\" AS line FIELDTERMINATOR '|'\nCREATE (:User {objectId: toInt(line[0]), age: toInt(line[1]), gender: line[2], occupation: line[3]});\n```\n\nCreate the Movies :\n\n```bash\nUSING PERIODIC COMMIT 500\nLOAD CSV FROM \"file:///u.item\" AS line FIELDTERMINATOR '|'\nCREATE (:Movie {objectId: toInt(line[0]), title: line[1], date: line[2], imdblink: line[4]});\n```\n\nCreate the Likes relationships with the ratings as relationship properties :\n\n```bash\nUSING PERIODIC COMMIT 500\nLOAD CSV FROM \"file:///u.data\" AS line FIELDTERMINATOR '\\t'\nMATCH (u:User {objectId: toInt(line[1])})\nMATCH (p:Movie {objectId: toInt(line[0])})\nCREATE UNIQUE (u)-[:LIKES {rate: ROUND(toFloat(line[2])), timestamp: line[3]}]-\u003e(p);\n```\n\n#### Query 1 : Simple search for movies with `love` in the title\n\n```bash\nGET /neo4j-index/_search?pretty HTTP/1.1\nContent-Length: 108\nAccept-Encoding: gzip, deflate\nHost: 192.168.99.100:9200\nAccept: application/json\nUser-Agent: HTTPie/0.9.2\nConnection: keep-alive\nContent-Type: application/json\n\n{\n  \"size\": 3,\n  \"query\" : {\n      \"bool\": {\n        \"should\": [{\"match\": {\"title\": \"love\"}}]\n      }\n  }\n}\n\n\nHTTP/1.1 200 OK\nContent-Type: application/json; charset=UTF-8\nContent-Length: 1189\n\n{\n  \"took\" : 6,\n  \"timed_out\" : false,\n  \"_shards\" : {\n    \"total\" : 5,\n    \"successful\" : 5,\n    \"failed\" : 0\n  },\n  \"hits\" : {\n    \"total\" : 29,\n    \"max_score\" : 2.9627202,\n    \"hits\" : [ {\n      \"_index\" : \"neo4j-index\",\n      \"_type\" : \"Movie\",\n      \"_id\" : \"1297\",\n      \"_score\" : 2.9627202,\n      \"_source\" : {\n        \"date\" : \"01-Jan-1994\",\n        \"imdblink\" : \"http://us.imdb.com/M/title-exact?Love%20Affair%20(1994)\",\n        \"title\" : \"Love Affair (1994)\",\n        \"objectId\" : \"1297\"\n      }\n    }, {\n      \"_index\" : \"neo4j-index\",\n      \"_type\" : \"Movie\",\n      \"_id\" : \"1446\",\n      \"_score\" : 2.919132,\n      \"_source\" : {\n        \"date\" : \"01-Jan-1995\",\n        \"imdblink\" : \"http://us.imdb.com/M/title-exact?Bye%20Bye,%20Love%20(1995)\",\n        \"title\" : \"Bye Bye, Love (1995)\",\n        \"objectId\" : \"1446\"\n      }\n    }, {\n      \"_index\" : \"neo4j-index\",\n      \"_type\" : \"Movie\",\n      \"_id\" : \"535\",\n      \"_score\" : 2.6663055,\n      \"_source\" : {\n        \"date\" : \"23-May-1997\",\n        \"imdblink\" : \"http://us.imdb.com/M/title-exact?Addicted%20to%20Love%20%281997%29\",\n        \"title\" : \"Addicted to Love (1997)\",\n        \"objectId\" : \"535\"\n      }\n    } ]\n  }\n}\n```\n\n#### Query2 : Filter out negatively rated movies from the ES results by using a Cypher filter :\n\n```bash\nGET /neo4j-index/_search?pretty HTTP/1.1\nContent-Length: 351\nAccept-Encoding: gzip, deflate\nHost: 192.168.99.100:9200\nAccept: application/json\nUser-Agent: HTTPie/0.9.2\nConnection: keep-alive\nContent-Type: application/json\n\n{\n  \"size\": 3,\n  \"query\" : {\n      \"bool\": {\n        \"should\": [{\"match\": {\"title\": \"love\"}}]\n      }\n  },\n  \"gas-filter\" :{\n      \"name\": \"SearchResultCypherFilter\",\n      \"query\": \"MATCH (n:User)-[r:LIKES]-\u003e(m) WITH m, avg(r.rate) as avg_rate where avg_rate \u003c 3 RETURN m.objectId as id\",\n      \"exclude\": true,\n      \"keyProperty\": \"objectId\"\n  }\n}\n\n\nHTTP/1.1 200 OK\nContent-Type: application/json; charset=UTF-8\nContent-Length: 1189\n\n{\n  \"took\" : 4,\n  \"timed_out\" : false,\n  \"_shards\" : {\n    \"total\" : 5,\n    \"successful\" : 5,\n    \"failed\" : 0\n  },\n  \"hits\" : {\n    \"total\" : 29,\n    \"max_score\" : 2.9627202,\n    \"hits\" : [ {\n      \"_index\" : \"neo4j-index\",\n      \"_type\" : \"Movie\",\n      \"_id\" : \"1297\",\n      \"_score\" : 2.9627202,\n      \"_source\" : {\n        \"date\" : \"01-Jan-1994\",\n        \"imdblink\" : \"http://us.imdb.com/M/title-exact?Love%20Affair%20(1994)\",\n        \"title\" : \"Love Affair (1994)\",\n        \"objectId\" : \"1297\"\n      }\n    }, {\n      \"_index\" : \"neo4j-index\",\n      \"_type\" : \"Movie\",\n      \"_id\" : \"1446\",\n      \"_score\" : 2.919132,\n      \"_source\" : {\n        \"date\" : \"01-Jan-1995\",\n        \"imdblink\" : \"http://us.imdb.com/M/title-exact?Bye%20Bye,%20Love%20(1995)\",\n        \"title\" : \"Bye Bye, Love (1995)\",\n        \"objectId\" : \"1446\"\n      }\n    }, {\n      \"_index\" : \"neo4j-index\",\n      \"_type\" : \"Movie\",\n      \"_id\" : \"535\",\n      \"_score\" : 2.6663055,\n      \"_source\" : {\n        \"date\" : \"23-May-1997\",\n        \"imdblink\" : \"http://us.imdb.com/M/title-exact?Addicted%20to%20Love%20%281997%29\",\n        \"title\" : \"Addicted to Love (1997)\",\n        \"objectId\" : \"535\"\n      }\n    } ]\n  }\n}\n\n```\n\n#### Query 3 : Exclude movies already rated by the User\n\nWe randomly choose the User with id `12`, this logic should be computed at the application level\n\n```bash\nGET /neo4j-index/_search?pretty HTTP/1.1\nContent-Length: 330\nAccept-Encoding: gzip, deflate\nHost: 192.168.99.100:9200\nAccept: application/json\nUser-Agent: HTTPie/0.9.2\nConnection: keep-alive\nContent-Type: application/json\n\n{\n  \"size\": 3,\n   \"query\" : {\n       \"bool\": {\n         \"should\": [{\"match\": {\"title\": \"love\"}}]\n       }\n   },\n   \"gas-filter\" :{\n        \"name\": \"SearchResultCypherFilter\",\n        \"query\": \"MATCH (n:User {objectId: 12})-[r:LIKES]-\u003e(m) RETURN m.objectId as id\",\n        \"exclude\": true,\n        \"keyProperty\": \"objectId\"\n   }\n}\n\n\nHTTP/1.1 200 OK\nContent-Type: application/json; charset=UTF-8\nContent-Length: 1189\n\n{\n  \"took\" : 9,\n  \"timed_out\" : false,\n  \"_shards\" : {\n    \"total\" : 5,\n    \"successful\" : 5,\n    \"failed\" : 0\n  },\n  \"hits\" : {\n    \"total\" : 29,\n    \"max_score\" : 2.9627202,\n    \"hits\" : [ {\n      \"_index\" : \"neo4j-index\",\n      \"_type\" : \"Movie\",\n      \"_id\" : \"1297\",\n      \"_score\" : 2.9627202,\n      \"_source\" : {\n        \"date\" : \"01-Jan-1994\",\n        \"imdblink\" : \"http://us.imdb.com/M/title-exact?Love%20Affair%20(1994)\",\n        \"title\" : \"Love Affair (1994)\",\n        \"objectId\" : \"1297\"\n      }\n    }, {\n      \"_index\" : \"neo4j-index\",\n      \"_type\" : \"Movie\",\n      \"_id\" : \"1446\",\n      \"_score\" : 2.919132,\n      \"_source\" : {\n        \"date\" : \"01-Jan-1995\",\n        \"imdblink\" : \"http://us.imdb.com/M/title-exact?Bye%20Bye,%20Love%20(1995)\",\n        \"title\" : \"Bye Bye, Love (1995)\",\n        \"objectId\" : \"1446\"\n      }\n    }, {\n      \"_index\" : \"neo4j-index\",\n      \"_type\" : \"Movie\",\n      \"_id\" : \"535\",\n      \"_score\" : 2.6663055,\n      \"_source\" : {\n        \"date\" : \"23-May-1997\",\n        \"imdblink\" : \"http://us.imdb.com/M/title-exact?Addicted%20to%20Love%20%281997%29\",\n        \"title\" : \"Addicted to Love (1997)\",\n        \"objectId\" : \"535\"\n      }\n    } ]\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphaware%2Fgraph-aided-search-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphaware%2Fgraph-aided-search-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphaware%2Fgraph-aided-search-demo/lists"}