I'm currently in the process of creating a chatbot designed to filter questions, and I'm seeking guidance on how to refine the search in my MongoDb based on user input.
At the moment, I have the following code:
I aim to retrieve all the results that match a word from the variable "words".
let text = this.messageEvent.data.text
var words= text.split(" ")
this.fetchDataFromDataSource({ channel: this.channel, collectionName: "62a985781cd96396e4e1cba3_test", filter: {
input:"$KeywordGroup1",
} }).then((result) => {
console.log(result)
})
Here is what my database currently looks like:
I am aiming to filter the results based on the user input. For instance, if a user enters "price," then it should return 3 entries from the database. However, if the user enters any other word, it should not return anything.
I prefer not to use the "find" method as it could potentially return more than one entry with that keyword.
Thank you for your assistance!