Skip to content

Ability to customize Fuse search options #67

@devcircus

Description

@devcircus

Issue

I've noticed that some of my search results aren't appearing in the spotlight search results. They're actually returned as dependencyQueryResults, which can be confirmed in alpinejs devtools, but they don't make it through Fuse to appear in the spotlight result list. By default, Fuse places importance on the beginning of the field that is being searched. Since the match is towards the end of the searched string, it is being ignored.

Example
String being searched: "TTU/JH COMM COLLEGE DESIGN CATALOG SAMPLES O# 492026578-7,8,9"

if my input search query is "492026578", this result doesn't make it to the result list. It IS however, part of the query results, but Fuse skips over it because the query string is at the end of the searched string.

Solution

Provide a way to customize the Fuse fuzzy matching options like location, distance, ignoreLocation, and threshold.

If I manually edit the spotlight.js file and set ignoreLocation to true, then the result shows on the page as expected.

I could attempt a PR, but may take a while.
I understand if you don't want to start tying your package down to the Fuse fuzzy search implementation, but maybe there's a way to add options that can be translated to those Fuse options. Then again, you may not want spotlight to be concerned with that stuff at all. If so, I understand.

Thanks for this great component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions