Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart search getting silly when search input contains spaces #10

Open
ghrlt opened this issue Dec 27, 2023 · 1 comment
Open

Smart search getting silly when search input contains spaces #10

ghrlt opened this issue Dec 27, 2023 · 1 comment
Assignees
Labels
bug Something isn't working (Issue)

Comments

@ghrlt
Copy link

ghrlt commented Dec 27, 2023

Searchable element example:

{
  "id": 29,
  "libelle": "Cheeseburger",
  "abbreviated": "cheeseburger",
  "abbreviatedClassification": "cheeseburger",
  "description": "",
  "price": "4.9",
  "category": {
    "id": 8,
    "libelle": "Burgers"
  }
}

Search query: Cheese burger
Sherlock usage:

Sherlock sherlock = Sherlock(
  elements: el,
  priorities: {
    'libelle': 3,
    'abbreviated': 2,
    'description': 2,
  },
);
var results = (await sherlock.search(input: searchQuery.value)).sorted().unwrap();

Results:

Desirable results:

Thanks for this package and the work you put on it. For more details on this issue, see our direct messages.

@antoninhrlt antoninhrlt self-assigned this Dec 27, 2023
@antoninhrlt antoninhrlt added the bug Something isn't working (Issue) label Dec 27, 2023
@antoninhrlt
Copy link
Owner

antoninhrlt commented Dec 27, 2023

Thanks. I see why this happens in smart search.
I'll fix this when I have time.

For those who need a quick solution, you can create a regex like this:

List<String> words = inputText.split(' ');
String searchRegex = '${words.join('|')}|${words.join('')}|${inputText}';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working (Issue)
Projects
None yet
Development

No branches or pull requests

2 participants