Order by relevance during keyword search
Order by relevance during keyword search
Hello,
I very much like the search feature of datatables, it's an amazingly usefull tool.
However I was wondering if it was possible to order the search results by "relevance" during the typing of keywords. (instead of the order which was previously selected)
By relevance I mean a little bit like in Sublime Text : when you search for something, the first results are those that match best the typed keywords.
e.g. when I type "xxxx yyyy", a record containing "xxxx yyyy" in the same property would be better above another having "xxxx" in one property and "yyyy" in another.
e.g. when I type "zzzzzzz" and one record contains in one property, exactly and nothing more than "zzzzzzz" this record would be better on top.
I imagine a relevance index should be computed at each keystroke to achive this.
Thanks for your input on this matter !
Answers
What you would have to do, as you say is compute the relevance on each search input and then enter that value into a column for that row. The table would be sorted on that column, thus giving the relevance ordering.
The key thing would be devising (or using an existing) relevance algorithm to get the relevance value.
Interested to hear if you look into this further - sounds like a fun thing to do!
Allan
This is may be a little too difficult for me.
But I'm sure this would be a very nice feature to add to the core of datatables.
It won't be added to DataTables core (far too much code weight) but it sounds like a fun thing for a plug-in.
Allan