I have around 5k data in the following format.
[
{
"userName": "Genevieve_Borer",
"emailId": "Josefina.Gislason@yahoo.com",
"userId": 85226,
"firstName": "Rodrick",
"lastName": "Baumbach",
"userType": "NATIVE",
"projectId": 2968
},
{
"userName": "Leora.Schowalter",
"emailId": "Cheyenne.Reilly12@hotmail.com",
"userId": 89821,
"firstName": "Ara",
"lastName": "Daniel",
"userType": "NATIVE",
"projectId": 2083
}
.
.
.
]
My requirement is to search users under a particular project. Also on top of that, I would like to do a fuzzy search using the user firstName and lastName.
Here is my code to search data based on the above criteria
lunr.search(`+projectId:${projectId} firstName:${query}~1`);
With the above code, I am getting users with the passed projectId but also few other users with different projectIds which are close to the searched one. For example, If I search for projectId:9876 I am getting results with projectIds 9877 and 9878. I followed the Term Presence topic in this doc https://lunrjs.com/guides/searching.html.