I’ve been following a lot of the brilliant youtube tutorials for search aggregations, and have succeeded in getting my search form to work, but I am having some difficulty with filenames fuzzy search.
To be more clear, here is some of my search index and my node code
Search index ( I am searching through an array of emails, and fileobjects.filename, and a string message.
{
"mappings": {
"dynamic": false,
"fields": {
"emailTo": {
"dynamic": false,
"fields": {
"email": {
"type": "string"
}
},
"type": "document"
},
"fileObjects": {
"dynamic": false,
"fields": {
"fileName": {
"type": "string"
}
},
"type": "document"
},
"message": {
"type": "string"
}
}
}
}
The search tester works in the atlas console.
But when searching for filenames with extensions for example a filename would be “document.docx”
if I search for a document, nothing will be returned, if I search for “document.do” fuzzy search will find the doc. my guess is that this has something to do with fuzzy logic, but can I use a wildcard here, without forcing the user to insert a * in their search query?
here is my aggregation query using the node sdk, what can I change in the fuzzy properties that it will basically ignore everything after the . in the filename? but I do want to allow the user to search for docx as well. thanks for your help.
const agg = [
{
'$search': {
'index': 'quicksend',
'text': {
'query': data.query,
'path': ["emailTo.email", "message","fileObjects.fileName"],
'fuzzy' : {
"maxEdits" : 1,
"maxExpansions" : 50
}
},
}
},
{
'$match' : {
'senderId' : data.senderId
}
}
]