首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不允许我设置以AWSKeyspace为后端的TTL

不允许我设置以AWSKeyspace为后端的TTL
EN

Stack Overflow用户
提问于 2022-11-14 13:36:34
回答 2查看 51关注 0票数 2

我使用AWSKeyspace (cassandra)和elasticsearch作为存储后端和索引后端。我有一个要求删除所有的边缘超过30天。在edge属性上设置TTL不像预期的那样工作(下面是错误)。

代码语言:javascript
复制
ERROR org.apache.tinkerpop.gremlin.jsr223.DefaultGremlinScriptEngineManager  - Could not create GremlinScriptEngine for gremlin-groovy
java.lang.IllegalStateException: javax.script.ScriptException: javax.script.ScriptException: 
java.lang.UnsupportedOperationException: The storage engine does not support TTL

我的剧本如下:

代码语言:javascript
复制
edgeId = mgmt.getPropertyKey("edge_id")
sourceId = mgmt.getPropertyKey("source_id")
severity = mgmt.getPropertyKey("severity")
source = mgmt.getPropertyKey("source")
createdAt = mgmt.getPropertyKey("created_at")
alertStatus = mgmt.getPropertyKey("alert_status")
investigationStatus = mgmt.getPropertyKey("investigation_status")
investigationPriority = mgmt.getPropertyKey("investigation_priority")
attributes = mgmt.getPropertyKey("attributes")
edgeType = mgmt.getPropertyKey("edge_type")

if (!mgmt.containsGraphIndex(edgeIndexName)) {
    mgmt.buildIndex(edgeIndexName, Edge.class).
            addKey(edgeType, Mapping.TEXT.asParameter()).
            addKey(tenant, Mapping.TEXT.asParameter()).
            addKey(severity, Mapping.DEFAULT.asParameter()).
            addKey(source, Mapping.TEXT.asParameter()).
            addKey(createdAt, Mapping.DEFAULT.asParameter()).
            addKey(investigationPriority, Mapping.DEFAULT.asParameter()).
            addKey(attributes, Mapping.TEXT.asParameter()).
            buildMixedIndex(indexBackendName)
}
makeEdgeCompositeIndex(mgmt, edgeCompositeIndexName, edgeId)
makeEdgeCompositeIndex(mgmt, edgeCompositeIndexName, sourceId)
// ###########
// Add TTL
// ###########
mgmt.setTTL(sourceId, Duration.ofDays(30))

我确实尝试过用cassandra替换AWSKeyspace,并在docker文件中运行相同的脚本,并且运行良好(TTL设置)。就像cassandra AWSKeyspace支持添加TTL一样。

EN

回答 2

Stack Overflow用户

发布于 2022-11-14 16:51:25

当使用Amazon时,需要使用如下语句启用TTL

代码语言:javascript
复制
ALTER TABLE my_table WITH CUSTOM_PROPERTIES={'ttl':{'status': 'enabled'}};
票数 2
EN

Stack Overflow用户

发布于 2022-11-15 19:26:07

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74432527

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档