Skip to content

Instantly share code, notes, and snippets.

@gahabeen
Created April 16, 2020 11:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gahabeen/6dd20e0dde244701c73590a5e3d8ec47 to your computer and use it in GitHub Desktop.
Save gahabeen/6dd20e0dde244701c73590a5e3d8ec47 to your computer and use it in GitHub Desktop.
CreateIndex({
  name: 'ngram_on_users',
  source: {
    collection: Collection('users'),
    fields: {
      search: Query(Lambda('instance', 
          Union(
            Union(Map([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], Lambda('min', NGram(LowerCase(Select(['data', 'first_name'], Var('instance'))), Var('min'), Var('min'))))),
            Union(Map([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], Lambda('min', NGram(LowerCase(Select(['data', 'last_name'], Var('instance'))), Var('min'), Var('min')))))
          )
      ))
    }
  },
  terms: [{ binding: 'search' }]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment