我正在研究neo4j数据库,我对它处理节点很新,但突然间我在查询中出错了。我无法解决这个问题我花了8小时来解决它但仍然没有得到任何解决方案。我在服务器端使用nodejs。
我的Neo4j查询:
MATCH (a : User)-[p : POSTS]->(b), (b)-[category : category]->(categoryNode : Category)
WITH a, p, b, categoryNode, toFloat(distance (point({latitude : 23.0751926, longitude : 72.5256395}),
point({latitude : b.latitude, longitude : b.longitude})) / 1000) as distance
WHERE (b.banned <> 1 OR NOT EXISTS(b.banned)) AND (distance <= 30)
AND (NOT EXISTS(b.sold) OR b.sold = 0) AND (b.latitude IS NOT NULL AND b.longitude IS NOT NULL)
AND (EXISTS (b.priceInUSD) OR b.priceInUSD IS NOT NULL)
OPTIONAL MATCH (commentsBy : User)-[c : Commented]->(b)
RETURN DISTINCT a.username AS username, a.fullName AS fullName,
a.profilePicUrl AS profilePicUrl, toInt(p.postedOn) AS postedOn,
p.type AS postsType, b.postId AS postId, b.productsTagged AS productsTagged,
b.place AS place, b.latitude AS latitude, b.longitude AS longitude, b.city AS city,
b.countrySname AS countrySname, b.mainUrl AS mainUrl,
b.thumbnailImageUrl AS thumbnailImageUrl, b.postCaption AS postCaption, b.hashTags AS hashtags,
b.imageCount AS imageCount, b.containerHeight AS containerHeight,
b.containerWidth AS containerWidth, b.productsTaggedCoordinates AS productsTaggedCoordinates,
b.hasAudio AS hasAudio, categoryNode.name AS category, categoryNode.mainUrl AS categoryMainUrl,
categoryNode.activeImageUrl AS cateoryActiveImageUrl, toFloat(b.priceInUSD) / 0.01623113104640268 AS price,
"HTG" AS currency , toInt(b.priceInUSD) AS priceInUSD, b.productName AS productName,
b.likes AS likes, b.thumbnailUrl1 AS thumbnailUrl1, b.imageUrl1 AS imageUrl1,
b.containerHeight1 AS containerHeight1, b.containerWidth1 AS containerWidth1,
b.imageUrl2 AS imageUrl2, b.thumbnailUrl2 AS thumbnailUrl2, b.containerHeight2 AS containerHeight2,
b.containerWidth2 AS containerWidth2, b.thumbnailUrl3 AS thumbnailUrl3,
b.imageUrl3 AS imageUrl3, b.containerHeight3 AS containerHeight3,
b.containerWidth3 AS containerWidth3, b.thumbnailUrl4 AS thumbnailUrl4,
b.imageUrl4 AS imageUrl4, b.containerHeight4 AS containerHeight4, b.containerWidth4 AS containerWidth4,
COLLECT (DISTINCT {commentBody : c.comments, commentedByUser : commentsBy.username,
commentedOn : c.createTime, commentId : ID(c)})[0..5] AS commentData, distance
ORDER BY distance ASC, priceInUSD ASC, postedOn DESC
SKIP 0 LIMIT 20;
执行此查询后,我收到如下错误:
{
"signature": 127,
"fields": [
{
"code": "Neo.ClientError.Statement.TypeError",
"message": "String is not a valid coordinate type."
}
],
"timings": {
"type": "client"
}
}
答案 0 :(得分:3)
b.latitude
和b.longitude
值可能是字符串(非浮点数),它们不是坐标的有效类型。
尝试更改此代码段:
point({latitude : b.latitude, longitude : b.longitude})
到此:
point({latitude : TOFLOAT(b.latitude), longitude : TOFLOAT(b.longitude)})
(或者,为了提高效率:首先将这些属性值更改为浮点数。)