I have a collection hosted on Atlas,
I currently have declared an Atlas Search index with the default configuration, but I am unable to use it to find documents that partially matches the text.
For instance, I have the following documents :
[
{
_id: 'ABC123',
designation: 'ENPHASE IQ TERMINAL CABLE 3PH-1 UD',
supplierIdentifier: 205919
},
{
_id: 'DEF456',
designation: 'ENPHASE CABLE VERT IQ 60/72CELLS 400VAC',
supplierIdentifier: 205919
},
{
_id: 'GHI789',
designation: 'P/SOLAR PC ASTROENERGY 275W 60 CELULAS',
supplierIdentifier: 206382
}
]
If I use the text search to search "EN", Nothing is returned :
[{ "$search" : { "index" : "default", "text" : { "query" : "EN", "path" : { "wildcard" : "*"}}, "count": {"type": "total"}}}]
No result
But if i use the regex search, my documents are correctly returned :
db.testproducts.aggregate([{ "$search" : { "index" : "default", "regex" : { "query" : "(.*)EN(.*)", "allowAnalyzedField" : true, "path" : { "wildcard" : "*"}}, "count": {"type": "total"}}}])
[
{
_id: 'ABC123',
designation: 'ENPHASE IQ TERMINAL CABLE 3PH-1 UD',
supplierIdentifier: 205919
},
{
_id: 'DEF456',
designation: 'ENPHASE CABLE VERT IQ 60/72CELLS 400VAC',
supplierIdentifier: 205919
},
{
_id: 'GHI789',
designation: 'P/SOLAR PC ASTROENERGY 275W 60 CELULAS',
supplierIdentifier: 206382
}
]
As the regex operator is pretty slow, how to achieve the same with the text search ?