Skip to content

thobalose/gas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gas

A docker-compose setup for the Graph-Aided Search demo.

This setup will automate the configuration and start-up of:

Getting up and running

$ docker-compose up -d
$ docker-compose logs

Configure GAS by defining Neo4j URL and enabling it:

$ curl -XPUT "http://localhost:9200/neo4j-index/_settings?index.gas.neo4j.hostname=http://localhost:7474&index.gas.enable=true"

You should see:

{"acknowledged":true}

If you get:

{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"neo4j-index","index":"neo4j-index"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"neo4j-index","index":"neo4j-index"},"status":404}

Create the index with curl and re-run:

$ curl -XPUT 'http://localhost:9200/neo4j-index'

Head on to localhost:7474 and start the import on the Neo4j browser:

CREATE CONSTRAINT ON (n:Movie) ASSERT n.objectId IS UNIQUE;

CREATE CONSTRAINT ON (n:User) ASSERT n.objectId IS UNIQUE;

USING PERIODIC COMMIT 500
LOAD CSV FROM "file:///ml-100k/u.user" AS line FIELDTERMINATOR '|'
CREATE (:User {objectId: toInt(line[0]), age: toInt(line[1]), gender: line[2], occupation: line[3]});

USING PERIODIC COMMIT 500
LOAD CSV FROM "file:///ml-100k/u.item" AS line FIELDTERMINATOR '|'
CREATE (:Movie {objectId: toInt(line[0]), title: line[1], date: line[2], imdblink: line[4]});

Check the ElasticSearch indices status:

$ curl -XGET http://localhost:9200/_cat/indices
yellow open neo4j-index 5 1 2625 0 475.3kb 475.3kb

$ curl -XGET http://localhost:9200/neo4j-index/User/_search
$ curl -XGET http://localhost:9200/neo4j-index/Movie/_search

Import relationships:

USING PERIODIC COMMIT 500
LOAD CSV FROM "file:///ml-100k/u.data" AS line FIELDTERMINATOR '\t'
MATCH (u:User {objectId: toInt(line[1])})
MATCH (p:Movie {objectId: toInt(line[0])})
CREATE UNIQUE (u)-[:LIKES {rate: ROUND(toFloat(line[2])), timestamp: line[3]}]->(p);

Try a simple query:

curl -X POST http://localhost:9200/neo4j-index/Movie/_search -d '{
  "query" : {
      "bool": {
        "should": [{"match": {"title": "love"}}]
      }
  }
}';