Skip to content

Matching numbers in an expected order #12

Description

@lukepighetti

Given a list of items:

id: 2
name: Aroostook Farmland

id: 22
name: Penobscot Bay

id: 29
name: Coastal Islands

I want to be able to type Penob and get a sorting with 22: Penobscot Bay item on top. This currently works.

I also want to be able to type 29 and get a sorting with 29: Coastal Islands item on top.

However, in my current implementation if I type 29 I get 2: Aroostook Farmland on top.

I can't seem to make the search results to have 29 match 29 better than 2.

I was expecting to be able to have search options on each weighted key, since the needs of matching 26 => 26 is different than the needs of matching penob to penobscot.

Any suggestions?

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(),
      ),
    ],
  ),
);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions