如果我向firebase数据库发出此查询,我可以看到数据
https://movielen4.firebaseio.com/movieLens/movies.json?orderBy="year"&equalTo=1990
JSON的片段:
"586": {
"genre": ["Children's", "Comedy"],
"title": "Home Alone ",
"year": 1990
},
"3773": {
"genre": ["Comedy"],
"title": "House Party ",
"year": 1990
},
"3661": {
"genre": ["Horror", "Sci-Fi", "Thriller"],
"title": "Puppet Master II ",
"year": 1990
},
但是如果我将查询更改为
https://movielen4.firebaseio.com/movieLens/movies.json?orderBy="genre"&equalTo="Comedy"
它会返回空结果,即使你可以看到我有数据。我的索引定义正确
{
"rules": {
"movieLens" : {
"movies" : {
".indexOn": ["genre", "year"]
},
"ratings": {
".indexOn": ["movieId", "rating", "userid", "timestamp"]
},
"users": {
".indexOn": ["age", "gender", "occupation", "userId", "zipCode"]
}
},
".read": true,
".write": true
}
}
我认为我看到空的结果,因为Genre是一个数组。查询成功一年,因为它只是一个值。有谁知道如何查询数据何时进入数组?