Lunr is doing a great job finding most results, but I can't figure out why it won't return multi-word strings contained in JSON arrays.
Here's a sample JSON file to get a sense of how my data is structured:
[{
"title": "Rolling Loud",
"date": "May 5–7",
"location": "Miami, FL, USA",
"rock-artists": [],
"hh-artists": ["Kendrick Lamar", "Future"],
"electronic-artists": [],
"other-artists": []
}]
When I search for "Miami" and "Future", lunr returns the festival. However when searching for "Kendrick" or "Kendrick Lamar", lunr doesn't return the festival.
Relevant code:
// initialize lunr
var idx = lunr(function () {
this.field('id');
this.field('title', { boost: 3 });
this.field('date');
this.field('location');
this.field('rockArtists', { boost: 3 });
this.field('hhArtists', { boost: 3 });
this.field('electronicArtists', { boost: 3 });
this.field('otherArtists', { boost: 3 });
// add festivals to lunr
for (var key in data) {
this.add({
'id': key,
'title': data[key].title,
'date': data[key].date,
'location': data[key].location,
'rockArtists': data[key]['rock-artists'],
'hhArtists': data[key]['hh-artists'],
'electronicArtists': data[key]['electronic-artists'],
'otherArtists': data[key]['other-artists']
});
}
});
Thanks!