Given the following Atlas Search Index and example data…
Atlas Search Index
{
mappings: {
dynamic: false,
fields: {
content: {
tokenization: 'edgeGram',
type: 'autocomplete'
},
title: {
tokenization: 'edgeGram',
type: 'autocomplete'
}
},
},
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 “document” and I’m expecting to get back both documents but getting back only the first.
Search Query
{
$search: {
index: 'DocumentSearch',
compound: {
minimumShouldMatch: 1,
should: [
{
autocomplete: {
path: 'title',
query,
score: { boost: { value: 4 } },
},
},
{
autocomplete: {
path: 'content',
query,
},
},
],
},
highlight: {
path: 'content',
},
},
}
What changes do I need to make to my query or index to support my desired outcome?