Hi @Divya_N_A1 - Welcome to the community 
Please see the below $search
examples based on the sample documents and search term you have provided.
$search
and it’s output with use of compound
and text
:
{
$search: {
"index": "default",
"compound": {
"should": [
{"text": {"query": "product", "path": "name", "fuzzy": {"maxEdits": 1}}},
{"text": {"query": "product", "path": "description", "fuzzy": {"maxEdits": 1}}}
]
}
}
}
/// Output:
[
{
_id: ObjectId("6552dc8181ae04007d21a862"),
name: 'second',
description: 'some products'
},
{
_id: ObjectId("6552dc8181ae04007d21a861"),
name: 'first product',
description: 'first description'
}
]
$search
and it’s output with queryString
:
{
"$search": {
"index": "default",
"queryString": {
"defaultPath": "name",
"query": "name:product~1 OR description:product~1"
}
}
}
/// Output:
[
{
_id: ObjectId("6552dc8181ae04007d21a862"),
name: 'second',
description: 'some products'
},
{
_id: ObjectId("6552dc8181ae04007d21a861"),
name: 'first product',
description: 'first description'
}
]
query string is "product"
in both cases.
I have only tested this on my test environment with the 3 sample documents you provided using the search term "product"
- If you have cases where these types of queries do not return the expected documents, please advise.
It’s recommended you do any testing of the above examples on a test environment first to ensure it meets your use case and requirements before trying on production.
Regards,
Jason