【问题标题】:How to delete the property of all the vertices with the same label name?如何删除具有相同标签名称的所有顶点的属性?
【发布时间】:2020-05-27 19:44:23
【问题描述】:

我有标签名称为 Campaign 的顶点。并且拥有一个 campaignType 属性,并且所有顶点的属性值为 offline。 我意外地更新了架构,但没有为campaignType 建立索引。 但是我非常需要这个来遍历在线活动。我尝试重新索引,但出现错误。我在stackoverflow中作为一个新问题询问了它,但我没有得到任何回应。所以删除该属性是我的第二个想法。 所以我想从所有活动顶点中删除该属性。 我试过了

    g.V().hasLabel('Campaign').hasProperty('campaignType').remove()

但出现错误

    Cannot invoke method remove() on null object

我期望的是所有顶点都应该出现,但只有活动类型属性应该被删除。我不知道我的问题有什么问题,但请帮助我克服它。

【问题讨论】:

    标签: gremlin janusgraph


    【解决方案1】:

    您可以使用properties 删除属性,然后使用drop

    g.V().hasLabel('Campaign').properties('campaignType').drop()
    

    【讨论】:

    • 已经尝试过了,但我收到一个错误提示 Could not find a suitable index to answer graph query and graph scans are disabled: [(~label = Campaign)]:VERTEX
    • 该广告系列类型属性没有索引
    • 通过像这样查询g.V().hasLabel('Campaign').has('active',true).properties('campaignType').drop(),我已经删除了属性值。但我想删除属性值和属性键。
    • 我想您可以临时配置query.force-index=false 以允许执行查询。假设这不是一个巨大的图表,答案中的查询应该做你想要的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-12
    • 2013-07-27
    • 2021-07-10
    • 1970-01-01
    相关资源
    最近更新 更多