builder_perf.js 795 B

123456789101112131415161718192021222324252627282930
  1. suite('lunr.Builder', function () {
  2. var documents = [{
  3. id: 'a',
  4. title: 'Mr. Green kills Colonel Mustard',
  5. body: 'Mr. Green killed Colonel Mustard in the study with the candlestick. Mr. Green is not a very nice fellow.',
  6. wordCount: 19
  7. },{
  8. id: 'b',
  9. title: 'Plumb waters plant',
  10. body: 'Professor Plumb has a green plant in his study',
  11. wordCount: 9
  12. },{
  13. id: 'c',
  14. title: 'Scarlett helps Professor',
  15. body: 'Miss Scarlett watered Professor Plumbs green plant while he was away from his office last week.',
  16. wordCount: 16
  17. }]
  18. this.add('build', function () {
  19. lunr(function () {
  20. this.ref('id')
  21. this.field('title')
  22. this.field('body')
  23. documents.forEach(function (doc) {
  24. this.add(doc)
  25. }, this)
  26. })
  27. })
  28. })