olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.89k stars 548 forks source link

Results aren't accurate for search #430

Open sosharma1403 opened 4 years ago

sosharma1403 commented 4 years ago
var lunr = require('lunr');
var documents = [{
  "name": "Lunr",
  "text": "this Like Solr, but much smaller, and not as #bright."
}, {
  "name": "React",
  "text": "A JavaScript library for building user interfaces."
}, {
  "name": "Lodash",
  "text": "A modern JavaScript utility library delivering modularity, performance & extras."
}]

var idx = lunr(function () {
  this.ref('name')
  this.field('text')

  documents.forEach(function (doc) {
    this.add(doc)
  }, this)
})

console.log(idx.search("#bright"));

Should return match for #bright

hoelzro commented 4 years ago

@sosharma1403 One way to fix this would be to add lunr.trimmer to this.searchPipeline in the lunr function invocation. @olivernn Do you think that would make sense to have in the search pipeline in the general case, or is there a reason that lunr.trimmer is in the indexing pipeline but not the search one?