mousemke / flounder

Style-able dropdown replacement for native dropdowns
MIT License
9 stars 10 forks source link

[Search] Score not correctly calculated #172

Closed conor-cafferkey-sociomantic closed 7 years ago

conor-cafferkey-sociomantic commented 7 years ago

Currently

Given a Flounder with:

{
    search : true,
    data   :
    [
        {
            text        : 'Knusper Müsli weniger süß',
            description : '30% weniger Zucker'
        }
    ]
}

A search value of Knusper returns no results (No matches found).

(The value Knusper Müsli correctly displays the option.)

~Problem~

~The search algorithm punishes non-matches of the description string. In the above case this leads to a score less than the minimum threshold (0).~

~Wanted~

~The search should not penalize non-matches of the description (or value) string.~

Turns out the solution is a lot simpler...

search.js line 319:

count = word.indexOf( queryWord ) !== -1 ? 1 : 0;

should be:

count += word.indexOf( queryWord ) !== -1 ? 1 : 0;
conor-cafferkey-sociomantic commented 7 years ago

~Also the weight given to descriptionSplit (the description string broken into words) seems too high / inconsistent with the others:~

weights : 
{
    text                : 30,
    textStartsWith      : 50,
    textFlat            : 10,
    textSplit           : 10,

    value               : 30,
    valueStartsWith     : 50,
    valueFlat           : 10,
    valueSplit          : 10,

    description         : 15,
    descriptionSplit    : 30
}

~Based on the other weights it seems like the “correct” value for descriptionSplit would be 5.~

Won’t change this.