GraphDb 索引策略

GraphDb Indexing Policies

考虑以下 json 回复..

如果您 运行 图形查询 g.V().hasLabel('customer'),响应是:

[
  {
    "id": "75b9bddc-4008-43d7-a24c-8b138735a36a",
    "label": "customer",
    "type": "vertex",
    "properties": {
      "partitionKey": [
        {
          "id": "75b9bddc-4008-43d7-a24c-8b138735a36a|partitionKey",
          "value": 1
        }
      ]
    }
  }
]

如果您 运行 sql 查询 select * from c where c.label = 'customer',响应是:

[
    {
        "label": "customer",
        "partitionKey": 1,
        "id": "75b9bddc-4008-43d7-a24c-8b138735a36a",
        "_rid": "0osWAOso6VYBAAAAAAAAAA==",
        "_self": "dbs/0osWAA==/colls/0osWAOso6VY=/docs/0osWAOso6VYBAAAAAAAAAA==/",
        "_etag": "\"2400985f-0000-0c00-0000-5e2066190000\"",
        "_attachments": "attachments/",
        "_ts": 1579181593
    }
]

Q: 鉴于 partitionKey 部分的结构差异,是否应将其引用为 /properties/partitionKey/*,或 /partitionKey/?索引政策?

目前我已经用...对冲了赌注

{
    "indexingMode": "consistent",
    "automatic": true,
    "includedPaths": [{
            "path": "/properties/partitionKey/*"
        },{
            "path": "/partitionKey/?"
        },{
            "path": "/label/?"
        }
    ],
    "excludedPaths": [{
            "path": "/*"
        },{
            "path": "/\"_etag\"/?"
        }
    ]
}

TIA!

这应该在您的索引策略中存储为“/partitionKey”,而不是“/properties/partitionKey”

顺便说一句,这里要指出的另一件事是,通常最好只排除您永远不会查询的路径,而不是必须包含您将要查询的路径。这样,如果您向图表添加属性,则无需重建索引即可查询新属性。