Firebaseを照会するためにREST APIを使用しています。Firebase for REST APIアクセスの2番目の子ノードのインデックス付け
ルールは以下のように設定されている:
{
"rules": {
".read": true,
".write": true,
"user": {
".indexOn": "type"
}
}
}
GETメソッド
https://exampleurl.firebaseio.com/user/9001.json
応答使ってURLの下に照会する場合:
{
"name": "Rohit",
"person": {
"-KLk3p3kUWg2j9p16kTw": {
"mobile": "9002",
"name": "Adarsh",
"type": "D"
},
"-KLk4x2V_hfZwlsh6PMo": {
"mobile": "9003",
"name": "Manas",
"type": "D"
},
"-KLk5-UPefdSMarC5VCQ": {
"mobile": "9004",
"name": "Sagar",
"place": "thane",
"type": "C"
}
}
}
をフィルタリングクエリを使用しているとき、私はエラーを取得しますGETメソッド
https://exampleurl.firebaseio.com/user/9001.json?orderBy="type"&startAt="D"
応答:
{
"error": "Index not defined, add \".indexOn\": \"type\", for path \"/user/9001\", to the rules"
}
私はルールの下に使用してみました。しかし、firebaseは私を保存することができません。
{
"rules": {
".read": true,
".write": true,
"user/9001": {
".indexOn": "type"
}
}
}
Another questionは、リスニングについて話します。私の質問はインデックス作成中ですが。
このような動的パス上のインデックスを定義することはできません。この種のクエリーを可能にするには、データ構造を変更する必要があります。 http://stackoverflow.com/questions/34363511/add-a-listener-to-a-child-inside-of-a-firebase-generated-keyを参照してください。 –