Old indexes don't work on FQL 10

Not sure if I’m doing something wrong but I have a database which have a few indexes, created using the regular FQL version, but when I try to use it on FQL 10 it does not work:

users.userByEmail("some@email.com").first()

it returns:

error: The function `userByEmail` does not exist on `users`

Index definition:

{
  name: "userByEmail",
  unique: true,
  serialized: true,
  source: "users",
  terms: [
    {
      field: ["data", "email"]
    }
  ]
}

Hi @BrunoQuaresma

FQL v4 indexes can’t be called directly in FQL v10, but indexed queries can be used in FQL v10 if they are embedded in a UDF. Similarly, FQL v10 indexes can’t be directly called from an FQL v4 query unless the indexed query is in a UDF.

See the v4 migration guide

For your example, you can create a UDF in v4 like

CreateFunction({
  name: "v4userByEmail",
  body: Query(
    Lambda('x', Paginate(Match(Index("userByEmail"), Var('x'))))
  )
})

Now you can call this function in both v4 and v10

v4 : Call("v4userByEmail", "hello@email.com")
v10: v4userByEmail("hello@email.com")

1 Like

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