NGram translates to Ngram: ReferenceError: Ngram is not defined

I have the following:

CreateIndex({
  name: 'searchUsersByName',
  terms: [
    { binding: 'search' }
  ],
  source: {
    collection: Collection('users'),
    fields: {
      search: Query(
        Lambda(
          ['row'],
          Union(
            NGram(
              LowerCase(
                Select(['data', 'firstName'], Var('row'))
              ),
              2,
              3
            ),
            NGram(
              LowerCase(
                Select(['data', 'middleName'], Var('row'))
              ),
              2,
              3
            ),
            NGram(
              LowerCase(
                Select(['data', 'surname'], Var('row'))
              ),
              2,
              3
            )
          )
        )
      )
    }
  }
});

And when I run fauna-schema-migrate generate, it generates the following:

CreateIndex({
  name: "searchUsersByName",
  terms: [{
    binding: "search"
  }],
  source: {
    collection: Collection("users"),
    fields: {
      search: Query(Lambda(["row"], Union(Ngram(LowerCase(Select(["data", "firstName"], Var("row"))), 2, 3), Ngram(LowerCase(Select(["data", "middleName"], Var("row"))), 2, 3), Ngram(LowerCase(Select(["data", "surname"], Var("row"))), 2, 3))))
    }
  }
})

Notice that NGram has been transformed into Ngram which is now incorrect. when I ran the migration, I got the following error:

Fauna Schema Migrate - 2.1.0
---------------------------------------
--- Starting subtask Retrieving current cloud migration state
--- Finished subtask Retrieved current migration state

Error in file: fauna/migrations/2021-05-02T03_43_07.746Z/create-index-searchUsersByName.fql
  Ngram is not defined

EDIT 1:

I tried manualy editing the generated migration to:

CreateIndex({
  name: "searchUsersByName",
  terms: [{
    binding: "search"
  }],
  source: {
    collection: Collection("users"),
    fields: {
      search: Query(Lambda(["row"], Union(NGram(LowerCase(Select(["data", "firstName"], Var("row"))), 2, 3), NGram(LowerCase(Select(["data", "middleName"], Var("row"))), 2, 3), NGram(LowerCase(Select(["data", "surname"], Var("row"))), 2, 3))))
    }
  }
})

I simply updated Ngram to NGram but got the same error with different trail.

Fauna Schema Migrate - 2.1.0
---------------------------------------
--- Starting subtask Retrieving current cloud migration state
--- Finished subtask Retrieved current migration state
--------- Current cloud migrations----------
    2021-03-28T10:48:52.250Z
    2021-04-17T02:03:19.186Z
    2021-04-17T09:15:39.642Z
--------- Current local migrations ----------
    2021-03-28T10:48:52.250Z
    2021-04-17T02:03:19.186Z
    2021-04-17T09:15:39.642Z
    2021-05-02T03:43:07.746Z
--------- Task ----------
    apply 1 migrations


--- Starting subtask [ DB: ROOT ] Generate migration code
  Ngram is not defined
Stacktrace ReferenceError: Ngram is not defined

I have updated to version 2.1.2 but still the same error as above.

Related: NGram translates to Ngram which will cause an error · Issue #42 · fauna-labs/fauna-schema-migrate · GitHub

1 Like

Hi @aprilmintacpineda ,

Thanks for reporting this. It looks like you’ve also reported it on the GitHub repo and it’s generated an issue for the JavaScript driver. Please keep an eye on that issue for any updates.

Cory

1 Like