i have a collection project which has several fields but i want to perform full text search in to 3 fields – projectName, projectSummery, title. there is one array which has all keywords to be searched in to 3 fields. if keyword is found in any field it should come in to result. it will be great if fuzzy search can also be included.
i have tried with following aggregation but it is not working. only results for last element in array is returned.
const variations = [water, waste, wastewater]
const aggregation = [
{
$search: {
index: “default”,
compound: {
should: variations.map(term => ({
compound: {
should: [
{
text: {
query: term,
path: “Type”,
score: { boost: { value: 10 } }
}
},
{
text: {
query: term,
path: “ProjectName”,
score: { boost: { value: 8 } }
}
},
{
text: {
query: term,
path: “ProjectSummary”
}
}
],
minimumShouldMatch: 1
}
})),
minimumShouldMatch: 1
}
}
},
{
$limit: 40
}
];