DottieDot / GTAV-NativeDB

https://nativedb.dotindustries.dev/
MIT License
53 stars 17 forks source link

Improve search #26

Open Sainan opened 2 years ago

Sainan commented 2 years ago

Right now, putting a space into the search query basically guarantees you won't get results, so it would be good to repurpose it as a separator for multiple keywords, giving queries such as "player from ped" a chance to return the respective native.

An example implementation:

auto words = string::explode(query, ' ');
for (const auto& word : words)
{
    if (item.find(word) == std::string::npos)
    {
        return false;
    }
}
return true;
DottieDot commented 2 years ago

Thanks for your suggestion,

I agree that the search algorithm could use some improvements, but this feels like a bandaid fix. I think a proper fuzzy search implementation would be preferable (fusejs perhaps?). I'm not exactly sure how this should be reflected in the UI, as the ranking of results is quite an essential aspect of such an approach. This change in UI could also be relevant for #8.

I'll look into it further once I get back from vacation.

Sainan commented 2 years ago

I don't know about "bandaid", I've looked at the problem of search matching quite a bit, and I find this to be more natural than fuzzy search. Tho I haven't bothered with ordering results.

DottieDot commented 2 years ago

What I meant with it being a bit of a bandaid solution is that it only addresses one shortcoming.

For example, I'd like a search for “vehicle color” to yield VEHICLE_COLOUR natives too.

Sainan commented 2 years ago

I do think it is good to not return a result if it would be a typo, as you do get some undesirable & illogical results, which is why I said I don't like the fuzzy approach.

Maybe a trivial algorithm to normalise the English dialect could solve this issue?

DottieDot commented 2 years ago

as you do get some undesirable & illogical results, which is why I said I don't like the fuzzy approach.

That's why I mentioned that the ranking of results is important. Having the most exact matches rank higher should mostly eliminate your concern. However, one issue with this approach is that it would be difficult to show the namespace boundaries...

I'll do some experimenting on what feels most natural.

Sainan commented 2 years ago

I suppose so, but I think this UI redesign is a bit of a burden on you, so just using 1 or 2 simple algorithms could improve search by a lot for not much work.

DottieDot commented 2 years ago

I have "temporarily" implemented your original suggestion in this commit as I'm unlikely to do the fuzzy search any time soon.

I'm still planning on doing it, but it has been moved to the "soon™" bucket.