Hi @wael_kassem - Thanks for providing those details.
/// Text search index called "synindex"
{
index: 'synindex',
text: {
query: 'car to the repair',
path: ['text']
},
highlight:{path: ['text']}
}
The following pipeline gets my matches, which isn’t expected because i didn’t include a synonyms parameter.
On my test environment using the lucene.standard
analyser, I do also get back the document you had mentioned using this search pipeline definition. I believe this behaviour is due to the following noted on the text
operator, specific to the query
field:
The string or strings to search for. If there are multiple terms in a string, Atlas Search also looks for a match for each term in the string separately.
Once I include the synonyms parameter , I don’t get matches anymore.
This does appear a bit odd due to the synonym working on the singular query example you provided above. Would you be able to provide:
- The search index definition
- The appropriate document(s) in the
source
collection where the synonyms for the example (I presume for the word car
) are defined. I have provided an example document at the very end of my reply
- Confirm if the below behaviour in my example is the behaviour you are expecting with the multi string
query
and synonyms
parameter used.
For the troubleshooting purposes, I have the following search pipeline using the synonyms parameter which does return the document you provided:
/// pipeline:
[{$search: {
index: 'synindex',
text: {
query: 'car to the repair',
path: ['text'],
synonyms:"syn"
},
highlight:{path: ['text']}
}}]
/// output document:
{
_id: ObjectId("62b23ed41585d2a73cdd92ec"),
text: 'I took my gasoline red vehicle to the repair shop'
}
Please note that if I change the query
value to "car"
, the same document is returned as well.
The source
collection document for the above example:
{
_id: ObjectId("62b25bf91585d2a73cdd92ed"),
mappingType: 'equivalent',
synonyms: [ 'car', 'vehicle', 'automobile' ]
}
Regards,
Jason