Skip to content

minhhien1996/mongoose-plugin-ngram-text-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

import nGramTextSearch from 'mongoose-plugin-ngram-text-search';

const userSchema = new mongoose.Schema({
  email: String,
  name: String,
  username: String,
  // your other fields...
});

// function used to extract to text to indexing from a field
const extractUsernameFromEmail = (str = '') => str.split('@')[0];

userSchema.plugin(nGramTextSearch, {
  nGramSizeMin: 1,
  nGramSizeMax: 8,
  edgeNGrams: true,
  fields: [
    { name: 'username' },
    { name: 'name' },
    { name: 'email', extractFn: extractUsernameFromEmail },
  ],
});

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published