Gremlin - AWS Neptune - Order by 属性 在顶点上不存在时出现问题
Gremlin - AWS Neptune - issue when Order by property which does not exist on a vertex
g.V().hasLabel('Asset').order().by('anyprop',decr).valueMap(true)
有时会抛出错误:
UnsupportedOperationException\",\"detailedMessage\":\"Encountered a traverser that does not map to a value for child traversal: value(anyprop)
我猜有些顶点没有 'anyprop' 属性.
我动态生成查询,所以 'anyprop' 可以是任何 属性,如何避免这个错误?
当 Neptune 上升到 3.5.x Apache TinkerPop 级别时,Gremlin 处理此类情况的方式会发生一些变化,这将阻止错误发生。在短期内,在键不存在的情况下,您可以只使用 coalesce
按默认值排序。请注意,我将 decr
更改为 desc
,因为 decr
现在已弃用。
g.V().hasLabel('Asset').
order().
by(coalesce(values('anyprop'),constant(0)),desc).
valueMap(true).limit(3)
g.V().hasLabel('Asset').order().by('anyprop',decr).valueMap(true)
有时会抛出错误:
UnsupportedOperationException\",\"detailedMessage\":\"Encountered a traverser that does not map to a value for child traversal: value(anyprop)
我猜有些顶点没有 'anyprop' 属性.
我动态生成查询,所以 'anyprop' 可以是任何 属性,如何避免这个错误?
当 Neptune 上升到 3.5.x Apache TinkerPop 级别时,Gremlin 处理此类情况的方式会发生一些变化,这将阻止错误发生。在短期内,在键不存在的情况下,您可以只使用 coalesce
按默认值排序。请注意,我将 decr
更改为 desc
,因为 decr
现在已弃用。
g.V().hasLabel('Asset').
order().
by(coalesce(values('anyprop'),constant(0)),desc).
valueMap(true).limit(3)