fomantic / Fomantic-UI

Fomantic-UI is the official community fork of Semantic-UI
https://fomantic-ui.com
MIT License
3.58k stars 333 forks source link

[Search] exact matches should be prioritized #827

Open maidzen opened 5 years ago

maidzen commented 5 years ago

Feature Request

When using search and more results are found then the limit, exact matches should be shown first

Example

icon car is not found but icons with "car" in name or with tag

Testcase (when possible)

https://fomantic-ui.com/elements/icon.html ->search car

Screenshot

image

*edit, better wording

MarianaES commented 3 years ago

Hello @lubber-de , I am not an experienced dev but I think I can try to solve this issue. 🙂

NotWearingPants commented 3 years ago

car is not an exact match since items in this dropdown look like the following:

{
    category: 'Automotive',
    title: '<i class="car icon"></i> car',
    description: 'auto, automobile, sedan, transportation, travel, vehicle',
    icon: 'car',
}

so the title is not exactly car since it has <i class="car icon"></i> (the title and description are the fields searched in).

But prioritizing whole words matches sounds like it would solve this.

The current search prioritizes items that start with the search term, and if fullTextSearch is specified in settings it appends fuzzy/in-the-middle matches afterwards.

Is the ordering we want the following? :

This is the current logic https://github.com/fomantic/Fomantic-UI/blob/d2b76da388a2bf3d505cca90b48416a8ae31e14e/src/definitions/modules/search.js#L658-L723

Lirt commented 8 months ago

Hi, I have different example to illustrate.

Let's assume following simple items (values) in dropdown:

Let's assume we search for butter.

The ordering can be different based on requirements of course. What you mentioned makes sense.

My personal view of ordering could be something like this:

My main question is, can I edit the search-sorting algorithm without editing Fomantic source code (in current release 2.9.3)? If we have interface where we can adjust the search, it would suit to everyone with different sorting taste :smile:. Otherwise some common agreement should be made.