olivernn / lunr.js

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

lunr.js + fuzzyset.js? #70

Closed dannydan412 closed 7 years ago

dannydan412 commented 10 years ago

Hey Oliver,

I was thinking of combining lunr with fuzzyset.js to allow for fuzzy searching. The idea is to modify the token store and replace the expand() method so that it uses the fuzzy matching results. The only problem is "similarityBoost" doesn't seem to provide sufficient penalty on matches that have a low fuzzy matching score (also between 0 and 1). Would you have any ideas on how to improve this?

uggrock commented 9 years ago

@dannydan412 , what is the status of this integration?

sanfilippopablo commented 9 years ago

This could be great.

cryptoquick commented 9 years ago

@dannydan412 @olivernn This feature would really complete this package. I could really make use of it. Was any work done towards this end?

khaledosman commented 9 years ago

+1

atamon commented 8 years ago

After tinkering with lunr trying to get it to fuzzy search by itself I stumbled upon this issue.

A quick hack gave me this:

var lunr = require('lunr');
var FuzzySet = require('fuzzyset.js');

var FUZZY_MATCH = 0.1;

var index = lunr(function () {
  this.field('title', { boost: 5 });
  this.field('path');
  this.ref('id');

  var titles = models.map(function (m) { return m.title; });
  var fuzzy = FuzzySet(titles);
  this.pipeline.add(function (token) {
    var matches = fuzzy.get(token);

    if (matches && matches[0][0] >= FUZZY_MATCH) return matches[0][1];
    else return token;
  });
});

The models in my example are simply objects where we're only interested in doing fuzzy search on their titles.

Integrating on application level is easy enough for simple cases at least :)

olivernn commented 7 years ago

The latest version of Lunr does not support fuzzy matching when performing searches.

shamrin commented 7 years ago

Correction to the above comment: Lunr does support fuzzy matching.