Algolia按子键值过滤

时间:2016-05-31 18:40:57

标签: search algolia

我的数据类似于一组:

{
  "creatorUsername": "mbalex99",
  "description": "For Hikers and All the Lovers Alike!",
  "imageUrl": "https://s3.amazonaws.com/edenmessenger/uploads/28C03B77-E3E9-4D33-A433-6522C0480C16.jpg",
  "isPrivate": true,
  "name": "Nature Lovers ",
  "roomId": "-KILq0nBN8wHQuEjMYRF",
  "usernames": {
    "bannon": true,
    "loveless": true,
    "mbalex99": true,
    "terra": true
  },
  "objectID": "-KILq0nBN8wHQuEjMYRF"
}

我无法找到密钥等于usernames的{​​{1}}?

1 个答案:

答案 0 :(得分:1)

这对Algolia来说确实是不可能的。您只能按值进行过滤 但是,您绝对可以添加一个包含对象键的数组,并按此属性进行过滤:

"usernames": {
  "bannon": true,
  "loveless": true,
  "mbalex99": true,
  "terra": true
},
"usernameList": ["bannon", "loveless", "mbalex99", "terra"]
// ...

// At query time:
{ "facetFilters": "usernameList:mbalex99" }