krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
17.79k stars 756 forks source link

Searching multiple keys only gets result for first key #578

Closed FrancoTanzarellaEviivo closed 2 years ago

FrancoTanzarellaEviivo commented 2 years ago

My simplified object looks like this


[
      {
        "id": 1234,
        "name": "Property one",
        "types": [
          {
            "id": 1,
            "name": {
              "text": "type 1"
            },
            "rooms": [
              {
                "id": 1,
                "name": {
                  "text": "Blue room"
                }
              },
             {
                "id": 2,
                "name": {
                  "text": "Red room"
                }
              },
            ]
          },
          {
            "id": 2,
            "name": {
              "text": "type 4"
            },
            "rooms": [
              {
                "id": 3,
                "name": {
                  "text": "Green room"
                }
              },
             {
                "id": 4,
                "name": {
                  "text": "Yellow room"
                }
              },
            ]
          },
        ],
       },
     ]

Fuse:

let roomSearch = new Fuse(properties ?? [], {
    findAllMatches: true,
    threshold: 0.3,
    isCaseSensitive: false,
    minMatchCharLength: 2,
    keys: ['name', 'types.name.text', 'types.rooms.name.text'],
  });

I can find name in the main array but can't find the other keys.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

FrancoTanzarellaEviivo commented 2 years ago

I still have this issue.