search tool doesn't do a great job #2016

Closed
valtido opened this Issue Oct 18, 2013 · 8 comments

Projects

None yet

6 participants

@valtido
valtido commented Oct 18, 2013

I typed jQuery, I got everything apart from jQuery itself...

I think the search func should be looked a bit more closer.

@ryankirkman
Member

You're absolutely right. We're looking into that now.

I think a good strategy could be to weight the search results by the number
of github stars on the project.

On Fri, Oct 18, 2013 at 5:15 AM, Valtid Caushi notifications@github.comwrote:

I typed jQuery, I got everything apart from jQuery itself...

I think the search func should be looked a bit more closer.


Reply to this email directly or view it on GitHubhttps://github.com/cdnjs/cdnjs/issues/2016
.

@valtido
valtido commented Oct 21, 2013

Perhaps, whatever works, but yeah it could get more traction should it find what you are looking for...

I have seen where people split each character and use wild cards so e.g:

Search: user
result:
-user.js
-users.js
-UndergroundSearchError.js

@RichardBronosky

I would like to see regex added so that I could find jQuery with "^jquery$"

@RichardBronosky

I was able to shoehorn this in by pasting thing into the JS console:

# from http://james.padolsey.com/javascript/regex-selector-for-jquery/
jQuery.expr[':'].regex = function(elem, index, match) {
    var matchParams = match[3].split(','),
        validLabels = /^(data|css):/,
        attr = {
            method: matchParams[0].match(validLabels) ? 
                        matchParams[0].split(':')[0] : 'attr',
            property: matchParams.shift().replace(validLabels,'')
        },
        regexFlags = 'ig',
        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
    return regex.test(jQuery(elem)[attr.method](attr.property));
}

Then I could search for the jQuery <tr> by [regex] name via:

jQuery(':regex(data-library-name,^jquery$)')

The I could show only the one I wanted via:

#from http://cdnjs.com/min.js
jQuery("[data-library-name]").hide(); jQuery(':regex(data-library-name,^jquery$)').show()

Worked like a charm!

I'd like to propose that at a minimum, we change this:

# http://cdnjs.com/min.js line#31/partial 
        (e("[data-library-name]").hide(), e('[data-library-name*="' + n + '"]').show(), e('[data-library-keywords*="' + n + '"]').show())

to:

# http://cdnjs.com/min.js line#31/partial 
        (e("[data-library-name]").hide(), e(':regex(data-library-name,' + n + ')').show(), e(':regex(data-library-keywords,' + n + ')').show())

Ideally, I'd like to add in the ability to search with "scope prefixes" similar to doing from:richard in Gmail. In this case that would be: name:jquery and keywords:testing and keyword:testing

@petecooper
Contributor

Collating search-related issues: #1829

@jimothyGator

It might also be useful to weight on the string length as well. So searching on "jquer", jquery would be weighted higher than jquery-ui, which would be weighted higher than jquery-history.

The rationale is that "jquery" is a more exact match than "jquery-ui". They'd each come up, but the sort order would prefer "jquery".

@ryankirkman
Member

This is fixed. I implemented search based on Damerau–Levenshtein distance and some other simple heuristics.

@jimothyGator This has the effect of weighting smaller library names higher as the edit distance is smaller between "jquer" and "jquery" than "jquery-validate".

@valtido A search for "jquery" will result in jquery being at the top now :)

@ryankirkman ryankirkman closed this Apr 9, 2014
@yeldarby

@ryankirkman - you are THE MAN. I did a search today for jquery and it finally appears at the top! This always bugged me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment