neo4j 的一些积累

  1. start本地neo4j

  2. 用记事本或者notepad++ 更改完neo4j config文件后:
    (1)去掉3个#
    (2)将0.0.0.0复制到两个冒号:之前
    neo4j 的一些积累_第1张图片

  3. 在google浏览器中,用http://本地cmd里面ipconfig加上:7474 这个网址,用户名test,密码1234登陆即可(在neo4j里面使用:server user add可以添加只有查看权限的用户test)

(1) 7474只是我电脑本地默认的http接口地址而已,具体更改与否,需要从neo4j的log窗口查看最终生成有效的网址到底是localhost://7474/…啥啥啥,因为有的时候电脑会变更neo4j的http的接口;
(2)其次,如果连接不上可以考虑cmd中输入ipconfig查看ip4地址,这个也可能会变更
(3) 最后一个小tips就是——项目右上角…克隆clone之后,原先通过browser的指令行 输入 :server user add 添加的user会没有,需要重新添加user, 一般来说,如果希望python 可以远程访问neo4j图数据库,都会建立一个叫做test 密码为1234的权限为reader的用户,届时在google中也是通过输入网址 ipconfig得到的ipv4(可能会变)+7474(可能会变) 通过输入账号密码test 密码为1234以只读权限访问调取图数据库中的信息。

# cypher语句记录
1. user实体导入
create constraint on (user:User) assert user.user_code is unique

using periodic commit
load csv with headers from 'file:///activeUser.csv' as row
merge (user:User{user_code:row.user_cd})

2.  kw实体导入
create constraint on (kw:KW) assert kw.user_input is unique

using periodic commita
load csv with headers from 'file:///kw15000.csv' as row
merge (kw:KW{user_input:row.kw})


3. series实体导入
CREATE CONSTRAINT ON (series:Series_code) ASSERT series.series_code IS UNIQUE

using periodic commit
load csv with headers from 'file:///series_code.csv' as row
merge (series:Series_code{series_code:row.series_code})


4. 导入relation
# (user:User{user_code:row.user_cd})
# (kw:KW{user_input:row.kw})
# (series:Series_code{series_code:row.series_code})

4.1 user_kw
using periodic commit
load csv with headers from 'file:///user_kw.csv' as row
match (user:User{user_code:row.user_cd}),(kw:KW{user_input:row.kw})
merge (user)-[r:search{searchtimes:row.searchtimes}]->(kw)
set r.searchtimes=toInteger(row.searchtimes)   #toInteger防止searchtimes列为str类型



4.2 kw_series
using periodic commit
load csv with headers from 'file:///kw_series.csv' as row
match (kw:KW{user_input:row.kw}),(series:Series_code{series_code:row.series_code})
merge (kw)-[r:click{clickNum:row.clickNum}]->(series)
set r.clickNum=toInteger(row.clickNum)

4.3 user_series_kw
using periodic commit
load csv with headers from 'file:///personal_click.csv' as row
match (user:User{user_code:row.user_cd}),(series:Series_code{series_code:row.series_code})
merge (user)-[r:personalClick {personalKW:row.kw, personalClick:row.personalClickNum}]->(series)
set r.personalClick=toInteger(row.personalClickNum)


【scenerio 1】的cypher语句
match (u:User)-[r:personalClick]->(series:Series_code) 
where series.series_code in ['110210176309','110300019720','110300026540']
return u.user_code,r.personalKW,r.personalClick,series.series_code limit 26

【scenerio 2】的cypher语句
match (kw:KW)-[r:click]->(series:Series_code) 
where  kw.user_input='轴承' and series.series_code in ['110210176309','110300019720','110300026540']
return kw.user_input, r.clickNum, series.series_code limit 26

【scenerio 3】的cypher语句
match (u:User)-[r:personalClick]->(series:Series_code) 
where u.user_code="1023971" and series.series_code in ['110210176309','110300019720','110300026540']
return u.user_code,r.personalKW,r.personalClick,series.series_code limit 26

【scenerio 4】的cypher语句
match (u:User)-[r:personalClick]->(series:Series_code) 
where r.personalKW='轴承'and series.series_code in ['110210176309','110300019720','110300026540']
return u.user_code,r.personalKW,r.personalClick,series.series_code limit 26


#USING PERIODIC COMMIT #让其自行调整,保证内存不被撑爆
#LOAD CSV with HEADERS from 'file:///sc_n4j.csv' as row
#merge (p1:Product{seriesCode:row.sc1})
#merge (p2:Product{seriesCode:row.sc2})
#merge (p1)-[r:JoinBuyCount]->(p2)
#set r.jointbuycount=toInteger(row.JointBuyCount) # toInteger防止JointBuyCount列为str类型





你可能感兴趣的:(Neo4j)