fuzzy_search_score
v1.0.4
Published
mongoose fuzzy search score
Downloads
1
Maintainers
Readme
fuzzy_search_score
This is a simple fuzzy search for mongo DB you can use it in the case of
- fuzzy search
- checking fuzzy search score
- separate object key score
- total score of object keys
fuzzy search
Any query
contact me on Linkedin kundan kumar .
Installation
Use the package manager fuzzy_search_score to install.
npm i fuzzy_search_score
Your Collection
Raw collection
{
"_id" : 1.0,
"name" : "Java,Java Hut,Cofff java",
"description" : "Coffee and cakes",
"price":50
},
{
"_id" : 2.0,
"name" : "Ja,Ma,Va",
"description" : "Gourmet hamburgers",
"price":99
}
....
Note this package work on aggregation don't use it in find etc.
Example-1 with mongoose aggregation
const {FuzzySearchScore}=require('fuzzy_search_score');
const data=await PRODUCT_TABLE.aggregate(FuzzySearchScore(['name','description'],
'my search keyword'),[]);
Example-2 with aggregation Condition
const {FuzzySearchScore}=require('fuzzy_search_score');
const data=await PRODUCT_TABLE.aggregate(FuzzySearchScore(['name','description'],
'my search keyword'),[
{$match:{Price:{$gt:25}}},
{$project:{
name:1,
description:1,
price:1,
score_name:1,
score_description:1,
TotalScore:1
}},
{$sort:{TotalScore:-1}}
]);
And you got this...
{
"_id" : 1.0,
"name" : "Java,Java Hut,Cofff java",
"description" : "Coffee and cakes",
"price":50,
"score_name":12,
"score_description":19,
"TotalScore":31},
{
"_id" : 2.0,
"name" : "Ja,Ma,Va",
"description" : "Gourmet hamburgers",
"price":99,
"score_name":3,
"score_description":12,
"TotalScore":15
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.