Skip to content

Instantly share code, notes, and snippets.

@grantm
Created Aug 29, 2012
Embed
What would you like to do?
Fix single colon in search queries
--- a/lib/MetaCPAN/Web/Controller/Search.pm
+++ b/lib/MetaCPAN/Web/Controller/Search.pm
@@ -22,6 +22,9 @@ sub index : Path {
$query =~ s{\.pm\b}{};
}
+ # normalise ":", "'" and "-" separators to "::"
+ $query =~ s{\b[:'-]\b}{::}g;
+
my $model = $c->model('API::Module');
my $from = ( $req->page - 1 ) * 20;
if ( $req->parameters->{lucky} ) {
@grantm
Copy link
Author

grantm commented Aug 29, 2012

This is meant to be a fix for the problem described here: http://blog.afoolishmanifesto.com/archives/1692 (i.e. the search query used a single ':' instead of '::')

Not sure is it has undesirable side-effects.

Are there legitimate reasons to use a single colon in a search like "word1:word2" ?

Is it a step too far to change apostrophes so that "don't" gets turned into "don::t" ?

@grantm
Copy link
Author

grantm commented Aug 29, 2012

s/Not sure is/Not sure if/

@monken
Copy link

monken commented Aug 30, 2012

yes, we have the dist:Moose syntax and more (author:PERLER, etc.)
This is lucene search syntax.

@dpetrov
Copy link

dpetrov commented Aug 31, 2012

let just exclude those like dist:, file:, module:, author:?

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