Create an index with a binding field is not working on the Dashboard Shell

Hey folks,

I’m trying to create the following index:

CreateIndex({
  name: "logs_by_createdAt_date",
  source: Collection("logs"),
  fields: {
    date: Query(Lambda("doc", Format("%F", Select(["data", "createdAt"], Var("doc")))))
  },
  terms: [{ binding: "date" }]
})

But looks like it is not working. The output is not showing the fields value:

{
  ref: Index("logs_by_createdAt_date"),
  ts: 1640888137600000,
  active: false,
  serialized: true,
  name: "logs_by_createdAt_date",
  source: Collection("logs"),
  terms: [
    {
      binding: "date"
    }
  ],
  partitions: 1
}

Thoughts? Thanks in advance!

I found the issues:

  • The fields param should live inside of the source param
  • The format option should be prefixed with a “t” like “%tF”

Here is the final query:

CreateIndex({
  name: "logs_by_createdAt_date",
  source: {
    collection: Collection("logs"),
    fields: {
      createdAtDate: Query(
        Lambda("doc", Format("%tF", Select(["data", "createdAt"], Var("doc"))))
      )
    }
  },
  terms: [{ binding: "createdAtDate" }]
})

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.