在Neo4j的cypher查询中,索引属性的Like搜索需要更多的时间

在Neo4j的cypher查询中,索引属性的Like搜索需要更多的时间,neo4j,cypher,Neo4j,Cypher,实体和Addess节点之间存在关系。实体在eid上具有唯一键约束,而Address在addressLocation上具有唯一键约束。 我有数百万个实体和地址的节点。精确搜索查询工作正常,下面是查询- match(e:Entity)-[r]->(a:Address) where a.addressLocation="ABC XYZ" return r match(e:Entity)-[r]->(a:Address) where a.addressLocation=~".*(?i)AB

实体和Addess节点之间存在关系。实体在eid上具有唯一键约束,而Address在addressLocation上具有唯一键约束。 我有数百万个实体和地址的节点。精确搜索查询工作正常,下面是查询-

match(e:Entity)-[r]->(a:Address) where a.addressLocation="ABC XYZ" return r
match(e:Entity)-[r]->(a:Address) where a.addressLocation=~".*(?i)ABC XYZ.*" return r
但就像搜索查询占用太多时间导致ReadTimeOutException一样。这是一个问题-

match(e:Entity)-[r]->(a:Address) where a.addressLocation="ABC XYZ" return r
match(e:Entity)-[r]->(a:Address) where a.addressLocation=~".*(?i)ABC XYZ.*" return r

有谁能告诉我应该怎么做才能尽快得到像搜索结果一样准确的搜索结果

第一个查询使用索引查找(在
Address.addressLocation
上):

第二个查询使用的正则表达式无法使用索引,因此性能不高:

match(e:Entity)-[r]->(a:Address) where a.addressLocation=~".*(?i)ABC XYZ.*" return r
MATCH (e:Entity)-[r]->(a:Addres)
WHERE a.addressLocation STARTS WITH "ABC XYZ"
RETURN r
Cypher有三个字符串比较运算符
开头,
结尾,
包含
<代码>以开头将使用索引,因此应执行此查询:

match(e:Entity)-[r]->(a:Address) where a.addressLocation=~".*(?i)ABC XYZ.*" return r
MATCH (e:Entity)-[r]->(a:Addres)
WHERE a.addressLocation STARTS WITH "ABC XYZ"
RETURN r

结尾,
包含
(这是您真正想要的)当前不使用索引,但是在Neo4j 3.0中,两者都将使用索引。如果您愿意尝试,可以使用里程碑版本的3.0。

谢谢William,这将非常有用。您知道Neo4j 3.0 stable relase何时推出吗