Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dallen66/bb9b2b938347733688c93c751599182b to your computer and use it in GitHub Desktop.

Select an option

Save dallen66/bb9b2b938347733688c93c751599182b 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