Given the following Atlas Search Index and example data…
Atlas Search Index
{
mappings: {
dynamic: false,
fields: {
title: {
type: 'string',
norms: 'omit',
},
content: {
type: 'string',
norms: 'omit',
},
},
},
name: 'DocumentSearch',
}
Example Data
[
{
_id: 1,
title: 'My first document',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
},
{
_id: 2,
title: 'My first_document',
content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit'
},
]
I’m trying to searching for “my document” and I’m expecting to get back both documents but getting back none. Additionally, searching for “my fir” returns no documents and I’d expect it to return both.
Search Query
{
$search: {
index: 'DocumentSearch',
compound: {
minimumShouldMatch: 1,
should: [
{
phrase: {
path: 'title',
query,
slop: 4,
score: { boost: { value: 3 } },
},
},
{
phrase: {
path: 'content',
query,
slop: 4,
},
},
],
},
highlight: {
path: 'content',
},
},
}
What changes do I need to make to my query or index to support my desired outcome?