15
我已經創造了火力地堡一個數據庫,它看起來像:「錯誤」:「沒有定義的索引,加上」 .indexOn」
現在我去爲REST客戶端,併發出此查詢:
https://movielens3.firebaseio.com/movieLens/users.json?orderBy="age"&startAt=25&print=pretty
它給了我一個錯誤:
"error": "Index not defined, add ".indexOn": "age", for path "/movieLens/users", to the rules"
所以,我走在規則部分,並將其定義RUL e:
{
"rules": {
"users" : {
".indexOn": ["age", "gender", "occupation", "zipCode"]
},
".read": true,
".write": true
}
}
但我仍然得到同樣的錯誤。
它解決了這個問題,但查詢「https://movielens3.firebaseio.com/movieLens/users.json?orderBy=」age「&startAt = 25&print = pretty'不會過濾任何東西。它會返回所有記錄 –
您將年齡存儲爲字符串。不是一個好主意。我還*認真*考慮創建自定義索引(僅僅是您維護的查找列表),因爲沒有這些索引就會很快遇到性能問題。查看此博客文章:https://www.firebase.com/blog/2013-04-12-denormalizing-is-normal.html和此文章:https://highlyscalable.wordpress.com/2012/03/01/ nosql的數據建模的技術/ –