comigor/fuzzy

Search results don't hone, they fluctuate

Opened this issue · 1 comments

This may be a configuration issue as I have no experience with fuzzy searching, opting into services like Algolia. However, I need an offline search-as-you-type feature and I'm looking for a similar experience.

Behavior: as you add characters the results alternate between a single result (sometimes missing expected results) and a bunch of seemingly unrelated results.

An example of missing results is typing penobscot and not getting back Mid-Penobscot River Valley or North Penobscot Farm-Woodlands

Expected: as you type more characters the results get more and more honed.

RPReplay_Final1608036795 2020-12-15 07_55_07

static final _districtFuse = Fuzzy(
  WmdConstants.districts,
  options: FuzzyOptions(
    keys: [
      /// WMD id, ie `23`
      WeightedKey<WmdModel>(
        name: 'id',
        weight: 1.0,
        getter: (e) => e.id.toString(),
      ),

      /// WMD name, ie `Penobscot Bay Area`
      WeightedKey<WmdModel>(
        name: 'name',
        weight: 0.1,
        getter: (e) => e.name.toString(),
      ),
    ],
  ),
);
final dataSet = {
  1: "Upper St. John River Valley",
  2: "Clayton Lake to St. Francis",
  3: "North Aroostook Farmland",
  4: "Chesuncook Lake to Daaquam",
  5: "Matagamon to Big Machias River",
  6: "Aroostook Farmland",
  7: "Rangeley Area",
  8: "Eustis to Jackman Area",
  9: "East of Moosehead Lake",
  10: "Foothills East of Baxter Park",
  11: "North Penobscot Farm-Woodlands",
  12: "Upper Androscoggin Valley",
  13: "Franklin and Somerset Co. Areas",
  14: "South and East of Moosehead Lake",
  15: "Oxford County Foothills",
  16: "Belgrade Lakes Area",
  17: "North-Central Farm-Woodlands",
  18: "Mid-Penobscot River Valley",
  19: "North of the Airline",
  20: "York County",
  21: "Cumberland County",
  22: "Kennebec River Valley",
  23: "South-Central Farm-Woodlands",
  24: "South Coastal Strip",
  25: "Mid-Coastal Strip",
  26: "Penobscot Bay Area",
  27: "Eastern Coastal Plain",
  28: "South of the Airline",
  29: "Maine’s Coastal Islands",
};

It seems weighted search had a couple of bugs. For example, weights are supposed to be normalized, so passing weight = 1.0 would already get unexpected results.

I've fixed this and a couple more things in https://github.com/luistrivelatto/fuzzy. Maybe you can test if the behaviour works better with that code?