Skip to content

Instantly share code, notes, and snippets.

@jasonaden
Created November 3, 2014 23:32
Show Gist options
  • Select an option

  • Save jasonaden/c4282eb2e2e4ad31b19e to your computer and use it in GitHub Desktop.

Select an option

Save jasonaden/c4282eb2e2e4ad31b19e to your computer and use it in GitHub Desktop.
searchTimeout = $interval(->
# Build more explicit query string to return better lucene results
# As of 2014-10-20 wildcard searches seem broken. i.e., `q=brendon+b*`
# returns a result as if it was `q=b*`, skipping all characters before
# the escaped space [ms]
formattedQuery = "#{queryString}*" unless hasSpace = / /.test queryString
if hasSpace
if css.isPhone(origQueryString)
formattedQuery = "phone:#{queryString}*"
else
formattedQuery = "name:#{queryString}*"
search = Customer.search(q:"#{formattedQuery}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment