2015-10-06 174 views
0

我有一種client是由實體與含有Key是否有可能在包含鍵

列表屬性psets的列表(value)屬性運行'的祖先過濾器/查詢使用JSON API psets這將表示爲:

psets = { listValue: [ {keyValue: { path: [...]} },{keyValue: { path: [...]} },... ]} 

的鍵值來製成的path = [{ kind: 'project', name: 'projectn' }]

我試圖運行「客戶」上的「祖先」查詢使用

SELECT * from client where psets HAS ANCESTOR KEY(project, 'project1') 

該查詢返回了一個錯誤:unsupported property

什麼是不支持?

如何在鍵列表上運行'HAS ANCESTOR'過濾器?

根據該DataStore Documentation(運營商和比較)

A condition can also test whether one entity has another entity as an ancestor, using the HAS ANCESTOR or HAS DESCENDANT operators. These operators test ancestor relationships between keys. They can operate on __key__, but they can also operate on a key-valued property. For HAS ANCESTOR, the right operand cannot be a property

(重點煤礦)

+1

這看起來像一個文檔錯誤。我正在努力解決這個問題,希望能提供更好的錯誤信息。 –

回答

1

數據存儲僅支持實體按鍵的HAS ANCESTOR運營商(即特殊__key__屬性),而不是請注意,定期的關鍵值。

可能的解決方法是將每個祖先明確包含在實體中作爲屬性。

因此,舉例來說,如果你的psets屬性包含一個關鍵project:project1/foo:2/bar:3,你能保持在包含project:project1project:project1/foo:2,並project:project1/foo:2/bar:3單獨psets_ancestors列表屬性。然後,你可以做平等查詢的psets_ancestors屬性:

SELECT * FROM client WHERE psets_ancestors = KEY(project, 'project1')

(這是以額外的索引條目的成本和需要維護單獨的列表屬性。)

相關問題