distance未走到索引
发布于 3 个月前 作者 bingo 183 次浏览 来自 问答

微信图片_20190408174225.png

6 回复

match(n:City) detach delete n; drop CONSTRAINT ON (cc:City) ASSERT cc.location IS UNIQUE ;

create CONSTRAINT ON (cc:City) ASSERT cc.location IS UNIQUE ;

CREATE (bruges2:City {name:“bruges”, location:point({srid:4326, x: 101.585997,y: 30.342134})}); CREATE (bruges:City {name:“bruges”, location:point({srid:4326, x: 102.585997,y: 30.342134})}); CREATE (brussels:City {name:“brussels”, location:point({srid:4326, x: 103.585997,y: 30.342134})}); CREATE (paris:City {name:“paris”, location:point({srid:4326, x: 104.585997,y: 30.342134})}); CREATE (paris1:City {name:“paris1”, location:point({srid:4326, x: 105.585997,y: 30.342134})}); CREATE (paris2:City {name:“paris2”, location:point({srid:4326, x: 106.585997,y: 30.342134})}); /CREATE (paris3:City {name:“paris3”, location:point({srid:4326, x: 107.585997,y: 30.342134})})/

explain match(c:City) WHERE distance(c.location, point({srid:4326, x:104.585997, y: 30.342134 }))< 200 RETURN c; --City节点中超过5条数据就不走索引

explain MATCH (c:City) where point({srid:4326,x:100,y:21})<c.location<point({srid:4326,x:104,y:28}) return c; --可以走到索引

版本是3.4 ,超过5条数据,distance 就会走不到索引

和数据量无关。distance()函数的第二个参数中把srid去掉: explain match(c:City) WHERE distance(c.location, point({x:104.585997, y: 30.342134 }))< 200 RETURN c; point数据类型的格式是:{x,y,crs}或{x,y,z,crs}

教授,我都试过了。而且longitude,和latitude也试过了。都用不到索引

5.png官网上好像说 也可以用srid吧

回到顶部