First time on this forum for ages and i have a tricky MongoDB query.
I'm using the node-red-node-mongodb nodes and I want to perform a query using wildcards. From the documentation, I have come up with the following as the msg.payload going into a 'mongodb in' node set to Find.
{"queriedProperty":{"wildcard:{"query":"<string with a ? or * >","allowAnalyzedField":true} }
But it doesn't work, and returns an 'empty' response. Any ideas anyone?
From what i gather your are searching for documents that have either a ? or a * in their values ?
What is the "path" field of your document you want to do a search on ? Is it called "queriedProperty" ?
maybe something like this ? (cannot test as i have the local mongodb)
msg.collection = "test"
msg.operation = "aggregate"
msg.payload = [
{
"$search": {
"wildcard": {
"path": "queriedProperty",
"query": ["*\\?*", "*\\**"] // can be a string or array of strings
}
}
}];
return msg;
* used to match any character before and after \\ is used to escape a character
Could the problem be that your JSON string is not valid? There are 3 open braces and only 2 close braces...
Does the node specifically state that the input msg.payload needs to be a string? If not, try passing that information as a Javascript object. At least that way you can't have invalid syntax, only bad data. ;*)