[{
$search: {
compound: {
must: [
{
wildcard: {
query: '*',
path: [
'fifa_id',
'ussf_id',
'email',
'competitions.name'
],
allowAnalyzedField: true
}
},
{
compound: {
mustNot: [
{
exists: {
path: 'deleted_at'
}
}
]
}
}
]
}
}
}, {
$sort: {
name_first: -1
}
}]
There are some examples here: https://www.mongodb.com/docs/atlas/atlas-search/tutorial/sort-tutorial/
Though this is quite similar to your own query. Did you have any issues?
I read your provide article and found 2 ways
- near operator which is used only for date and number type data.
- $sort
But As described before my sorting perform on alphabetical order. So I used $sort But the issue is $sort work too slow on large dataset for example below:
MyDataSetCount Approx: 2 Lacs
[{
$search: {
compound: {
must: [
{
wildcard: {
query: '*',
path: [
'a_id',
'sf_id',
'email',
'tutions.name'
],
allowAnalyzedField: true
}
},
{
compound: {
mustNot: [
{
exists: {
path: 'deleted_at'
}
}
]
}
}
]
}
}
}, {
$sort: {
name_first: 1
}
}]
Other Qyery format :
[{
$search: {
compound: {
must: [
{
wildcard: {
query: '*com*',
path: [
'a_id',
'sf_id',
'email',
'tutions.name'
],
allowAnalyzedField: true
}
},
{
compound: {
must: [
{
text: {
query: 'male',
path: 'gender'
}
}
]
}
},
{
wildcard: {
path: 'name_first',
query: '*mo*',
allowAnalyzedField: true
}
},
{
wildcard: {
path: 'name_last',
query: '*sh*',
allowAnalyzedField: true
}
},
{
compound: {
mustNot: [
{
exists: {
path: 'deleted_at'
}
}
]
}
}
]
}
}
}, {
$sort: {
name_first: 1
}
}]
Did you try it with Stored Source? https://www.mongodb.com/docs/atlas/atlas-search/stored-source-definition/
Hi Elle,
Yes I tried Source in our indexing like below but result same (too slow):
{
"mappings": {
"dynamic": true
},
"storedSource": {
"include": [
"name_first"
]
}
}
Okay, we are working on a solution for this. You can follow progress here. We hope to have something soon!