0

考虑以下 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
    }
]

问:由于该部分的结构存在这种差异partitionKey,应该将其引用为/properties/partitionKey/*,还是/partitionKey/?在索引策略中?

目前我已经通过与...的赌注进行对冲。

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

蒂亚!

4

1 回答 1

0

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

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

于 2020-01-16T18:51:28.597 回答