Fuzzy search same model, but different fields
See original GitHub issueHi.
I have and model named Article that contains the tilte and content .
let mongoose = require('mongoose');
let Schema = mongoose.Schema;
var mongoose_fuzzy_searching = require('mongoose-fuzzy-searching');
var ArticleSchema = new Schema({
title: {
type: String,
},
content: {
type: String,
},
})
module.exports = mongoose.model('Article', ArticleSchema);
The model is exported and used in another .js. How can I fuzzy search the title and content separately, without declaring
ArticleSchema.plugin(mongoose_fuzzy_searching, {fields: ['title', 'content']});
in the model schema file?
I want to have 2 functions that search articles one by the title, and the other one by the content, separately.
If I put the
ArticleSchema.plugin(mongoose_fuzzy_searching, {fields: ['title', 'content']});
then my both functions will use title and content for the fuzzy search.
Can I achieve something like this?
function a() {
ArticleSchema.plugin(mongoose_fuzzy_searching, {fields: ['title']});
fuzzySearch();
}
function b() {
ArticleSchema.plugin(mongoose_fuzzy_searching, {fields: ['content']});
fuzzySearch();
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Fuzzy Matching | String-Searching Algorithms & Example
Fuzzy matching allows you to identify non-exact matches of your target item. It is the foundation stone of many search engine frameworks and ......
Read more >Fuzzy Matching or Fuzzy Logic Algorithms Explained - Nanonets
Fuzzy Matching (also called Approximate String Matching) is a technique that helps identify two elements of text, strings, or entries that are ...
Read more >Fuzzy Matching 101: Cleaning and Linking Messy Data
Fuzzy matching identifies the likelihood that two records are a true match based on whether they agree or disagree on the various identifiers....
Read more >There's more to fuzzy search than correcting typos | Algolia Blog
Fuzzy search matches words even if there are typos or misspellings, and fuzzy matching finds information based on similarities.
Read more >What is a Fuzzy Search? - TechTarget
What are the pros and cons of fuzzy matching? · It sometimes returns too many results, requiring the user to sift through all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
But this is a very nice idea though, I will add it on the backlog.
so if I have
const Post = PostSchema.plugin(mongoose_fuzzy_searching, {fields: ['start', 'end']})
and then, without fuzzy search, I would search like this:
Post.find({ start: "abc", end: "def, })
With this package, there will not be a way to fuzzy search different strings for each of the fields “start” and “end”?