Suppose my data returns like this form :-
[
{
"_id": "611bc112431d9c0b44161968",
"title": "Nillkin Case for Apple iPhone 7 / Apple iPhone SE2 SE 2 iPhone SE 2020 (4.7\" Inch) Sparkle Leather Flip Folio Book Type PC Gold Color ",
"price": 353585
},
{
"_id": "611bc112431d9c0b4416198d",
"title": "Nillkin Case for Apple iPhone 8 / Apple iPhone SE2 SE 2 iPhone SE 2020 (4.7\" Inch) Sparkle Leather Flip Folio Book Type PC Gold Color ",
"price": 13255
},
{
"_id": "611bc112431d9c0b44161937",
"title": "Apple iPhone XR (64GB) - Black ",
"price": 40000
},
{
"_id": "611bc112431d9c0b44161992",
"title": "New Apple iPhone 12 (128GB) - Blue with Apple Clear Case with Magsafe (for iPhone 12, 12 Pro) ",
"price": 12000
},
{
"_id": "611bc112431d9c0b441619d5",
"title": "New Apple iPhone 12 (128GB) - Green with Apple Clear Case with Magsafe (for iPhone 12, 12 Pro) ",
"price": 40000,
},
{
"_id": "611bc112431d9c0b441619ed",
"title": "New Apple iPhone 12 (128GB) - Blue with Apple Clear Case with Magsafe (for iPhone 12, 12 Pro) ",
"price": 15680,
},
{
"_id": "611bc112431d9c0b441619f3",
"title": "New Apple iPhone 12 (256GB) - Black with Apple Clear Case with Magsafe (for iPhone 12, 12 Pro) ",
"price": 60000,
},
{
"_id": "611bc112431d9c0b44161a33",
"title": "New Apple iPhone 12 (64GB) - Black with Apple Clear Case with Magsafe (for iPhone 12, 12 Pro) ",
"price": 432525,
},
{
"_id": "611bc112431d9c0b44161a37",
"title": "New Apple iPhone 12 (64GB) - Blue with Apple Clear Case with Magsafe (for iPhone 12, 12 Pro) ",
"price": 55000,
},
{
"_id": "611bc112431d9c0b44161a4c",
"title": "New Apple iPhone 12 (128GB) - Black with Apple Clear Case with Magsafe (for iPhone 12, 12 Pro) ",
"price": 2244,
},
{
"_id": "611bc112431d9c0b4416192c",
"title": "New Apple iPhone 11 (128GB) - Black ",
"price": 13255,
},
{
"_id": "611bc112431d9c0b4416192d",
"title": "New Apple iPhone 12 (128GB) - Green ",
"price": 432525,
},
{
"_id": "611bc112431d9c0b4416192e",
"title": "New Apple iPhone 11 (64GB) - Black ",
"price": 34342,
},
{
"_id": "611bc112431d9c0b4416192f",
"title": "New Apple iPhone 12 (128GB) - Blue ",
"price": 353585,
},
{
"_id": "611bc112431d9c0b44161930",
"title": "New Apple iPhone 11 (64GB) - Purple ",
"price": 66430,
}
]
I know very well that if I use $sort then its arranges the data format in ascending and descing form.
but I want my data returned like this: (DYNAMICALLY RANKING)
[
{
"_id": "611bc112431d9c0b44161968",
"title": "Nillkin Case for Apple iPhone 7 / Apple iPhone SE2 SE 2 iPhone SE 2020 (4.7\" Inch) Sparkle Leather Flip Folio Book Type PC Gold Color ",
"price": 9000
},
{
"_id": "611bc112431d9c0b4416198d",
"title": "Nillkin Case for Apple iPhone 8 / Apple iPhone SE2 SE 2 iPhone SE 2020 (4.7\" Inch) Sparkle Leather Flip Folio Book Type PC Gold Color ",
"price": 8000
},
{
"_id": "611bc112431d9c0b44161937",
"title": "Apple iPhone XR (64GB) - Black ",
"price": 12000
},
{
"_id": "611bc112431d9c0b44161992",
"title": "New Apple iPhone 12 (128GB) - Blue with Apple Clear Case with Magsafe (for iPhone 12, 12 Pro) ",
"price": 8500
}
]
My aggeration
Pipeline = [{
'$search': {
'text': {
'query': `Iphone`,
'path': 'title',
}
}
} ]
Now, Any one please Suggest me the solution guys