resolution for issue #151 - search with multiple words
This commit is contained in:
parent
c646db956e
commit
94f20ba684
1 changed files with 17 additions and 2 deletions
|
|
@ -34,8 +34,23 @@ class Person
|
||||||
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
||||||
|
|
||||||
def self.search(query)
|
def self.search(query)
|
||||||
query = Regexp.escape( query.to_s.strip )
|
qTokens = query.to_s.strip.split(" ")
|
||||||
Person.all('profile.first_name' => /^#{query}/i) | Person.all('profile.last_name' => /^#{query}/i)
|
fullQueryText = Regexp.escape( query.to_s.strip )
|
||||||
|
|
||||||
|
p = Person.all('profile.first_name' => /^#{fullQueryText}/i) \
|
||||||
|
| Person.all('profile.last_name' => /^#{fullQueryText}/i)
|
||||||
|
|
||||||
|
qTokens.each {
|
||||||
|
|token|
|
||||||
|
|
||||||
|
q = Regexp.escape( token.to_s.strip )
|
||||||
|
p = Person.all('profile.first_name' => /^#{q}/i) \
|
||||||
|
| Person.all('profile.last_name' => /^#{q}/i) \
|
||||||
|
| p
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
end
|
end
|
||||||
|
|
||||||
def real_name
|
def real_name
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue