Hello, I need some help with a query I’m trying to do, I hope you can find what’s wrong here . For info, we are using Mongo Atlas Search
What I had : A collection with an index on multiple string fields, with a working aggregate query on it.
What I want : To include in this index a “number” type field (int32) so I can use the same search bar to search an item by number, instead of name or description.
I looked at the documentation and updated the index, but my query never returns anything. The query works if I search for something in others fields as in Name.fr-CA or Description.fr-CA, but not in Number.
An example of data, my collection contains many items as this one :
{
“_id” : ObjectId(“010000000000000000000003”),
“Description” : {
“fr-CA” : “Un lot de test”,
“en-CA” : “A test item”
},
“Name” : {
“fr-CA” : “Lot de test”,
“en-CA” : “Test item”
},
“Number” : 345,
“Partners” : [],
}
The default index of the collection :
{
“mappings”: {
“dynamic”: false,
“fields”: {
“Description”: {
“fields”: {
“en-CA”: {
“analyzer”: “lucene.english”,
“searchAnalyzer”: “lucene.english”,
“type”: “string”
},
“fr-CA”: {
“analyzer”: “lucene.french”,
“searchAnalyzer”: “lucene.french”,
“type”: “string”
}
},
“type”: “document”
},
“Name”: {
“fields”: {
“en-CA”: {
“analyzer”: “lucene.english”,
“searchAnalyzer”: “lucene.english”,
“type”: “string”
},
“fr-CA”: {
“analyzer”: “lucene.french”,
“searchAnalyzer”: “lucene.french”,
“type”: “string”
}
},
“type”: “document”
},
“Number”: [
{
“representation”: “int64”,
“type”: “number”
}
],
“Partners”: {
“fields”: {
“Name”: {
“type”: “string”
}
},
“type”: “document”
}
}
}
}
And finally the query I’m trying to do. I’ll need to generate this in C#, but for now I’m trying directly with mongoShell
db.[myDB].aggregate([{ $search: { "index": "default", "text": { "query": "345", "path": ["Number"]}}}])
Does anybody sees what I’m missing ? Hope you can help ! Thanks