'no matching index found' 使用 ORDER BY 时

'no matching index found' when using ORDER BY

我已经解决了所有问题并创建了大量独立工作的索引,但是第二次我尝试添加一个 ORDER BY 我得到一个 'no matching index found.' 错误

这些是我正在使用的索引

indexes:
- kind: gallery-public
  properties:
  - name: public
  - name: flavor
  - name: created
    direction : desc
- kind: get-selfies
  properties:
  - name: flavor
  - name: public
  - name: created
    direction: desc
- kind: get-selfies
  properties:
  - name: flavor
  - name: created
    direction: asc
- kind: get-all
  properties:
  - name: public
  - name: created
    direction: desc
- kind: get-all-old
  properties:
  - name: public
  - name: created
    direction: asc
- kind: get-all-two
  properties:
  - name: flavor
  - name: created
    direction: desc

每个查询都有效

SELECT * FROM upload WHERE flavor="whatever" AND public=true

直到我添加了一个ORDER BY,在这种情况下没有任何效果。如:

SELECT * FROM upload WHERE public=true ORDER BY created DESC

我已经创建了所有这些索引,明确定义了描述,将订单字段留到了最后,但我仍然无法让它工作。我错过了什么?

该查询返回的属性多于 publiccreatedflavor

改为:

SELECT public,created,flavor FROM upload WHERE public=true ORDER BY created DESC

如果不是这样,请提供 SELECT * 的示例记录。

查询返回的任何 属性(字段)也必须是您的自定义索引的一部分。

您需要为种类添加索引 upload:

- kind: upload
  properties:
  - name: public
  - name: created
    direction: desc

仅供参考 没有 ORDER BY 的查询成功,因为它可以在 属性 public 上使用 built-in single property index。通过添加 ORDER BY,您需要在 publiccreated 属性上都有一个复合索引。