Hi, I’m working on a feature in which we need to search by name in our database. The search works fine for single word queries, but when I input a string with spaces in it (2 or more words), the results are not accurate, because it returns different documents which match only one of the words that I inputted. From what I have read on a similar post on this forum, it might be a tokenization issue and the person which fixed it made a fix which works for exact matches, here I need an autocomplete solution for this issue.
Hi, here is my index:
{
"mappings": {
"dynamic": true,
"fields": {
"groupTag": {
"type": "autocomplete"
},
"name": {
"type": "autocomplete"
}
}
}
}
Here is my document:
{
"_id": {
"$oid": "63e4f8a261f74736f0fcc8b6"
},
"_v": 4,
"groupTag": "T-2",
"createdAt": {
"$date": {
"$numberLong": "1675950242663"
}
},
"updatedAt": {
"$date": {
"$numberLong": "1676022397735"
}
},
"name": "Dan test group",
}
And if I search for the name “Dan test group”, the search feature returns me other documents which contains in the name field any of the words “Dan”, “test”, “group”, and I end getting information that I didn’t search for. I need the search to return documents which name contains the entire string that I typed (“Dan test group”).