This Is the method which i used.Is there a better solution than this.(accuracy and efficient)
< collections = collection_name.aggregate(
[
{
"$search": {
"index": 'name_id',
"compound": {
"should": [
{
"autocomplete": {
"path": "name",
"query": search_key,
}
},
{
"autocomplete": {
"path": "contractId",
"query": search_key,
}
}
],
"minimumShouldMatch": 1
}
}
},
{
'$match': {"_id": {'$gt': ObjectId(start_id)}}
},
{
"$limit": int(70000)
},
{
"$sort": {'_id': 1}
},
{
"$limit": int(limit)
},
]) />