Skip to content

Instantly share code, notes, and snippets.

View joeljunstrom's full-sized avatar
🥰

Joel Junström joeljunstrom

🥰
  • Stockholm, Sweden
View GitHub Profile
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":"SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[unicef_production_registrations][0]: RemoteTransportException[[Sunset Bain][inet[/172.31.13.218:9300]][indices:data/read/search[phase/query+fetch]]]; nested: SearchParseException[[the-collection][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"function_score\":{\"functions\":[{\"script_score\":{\"script\":\"(0.08 / ((3.16*pow(10,-11)) * abs(now-doc['created'].date.getMillis()) + 0.05)) + 1.0\",\"params\":{\"now\":1429858855000}}}],\"query\":{\"filtered\":{\"query\":{\"multi_match\":{\"query\":\"some name\",\"type\":\"cross_fields\",\"fields\":[\"_all\"],\"operator\":\"or\"}},\"filter\":{\"exists\":{\"field\":\"created\"}}}}}},\"size\":20,\"from\":0}]]]; nested: QueryParsingException[[the-collection] script_score the script could not be loaded]; nested: IllegalArgumentException[Unrecognized method call (d
# Usage
# @assets = Asset.my_filter(params[:filter]).public.all # works like a charm
# @assets = @account.assets.my_filter(params[:filter]).public.paginate({
# :page => (params[:page] || 1)
# }) # works BUT (ofc) does not adhere to the @account scope
#
# initializer
ActiveRecord::Base.send :include, Spock::Base::Filterable
ActiveRecord::Base.send :include, Spock::Base::Filterable
module Spock
module Base
module Filterable
def self.included(base)
base.extend ClassMethods
end
module Spock
module Base
module Filterable
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def filter(f)
---
cwd: /home/unicef/staging/current
port: "9070"
user: unicef
group: mongrel
environment: staging
address: 127.0.0.1
pid_file: log/mongrel.pid
servers: 2
require File.dirname(__FILE__) + '/../test_helper'
class MashAppTest < ActiveSupport::TestCase
context "A MashApp instance" do
setup do
@mash_app = Factory.create(:mash_app)
end
# Allow the metal piece to run in isolation
require File.expand_path('../../../config/environment', __FILE__) unless defined?(Rails)
class AutoComplete
def self.call(env)
if env["PATH_INFO"] =~ /^\/auto_complete\/tags/
params = Rack::Request.new(env).params
sql = "SELECT name
FROM tags
WHERE name LIKE #{ActiveRecord::Base.connection.quote(params['q']+'%')}
apps_controller:
def search
@query = params[:query]
@search = App.search(@query)
respond_with(@search)
end
app.rb:
class << self
var $search = $('<input type="search">'),
$button = $('<button>Search</button>'),
$result_container = $('<div id="app_search_result" />'),
$app_list = $('#apps');
var $app_form = $(this).after($search, $button, $result_container).detach();
$search.data('search_context', 'local');
$search
$.fn.appForm = function() {
return this.each(function() {
var $search = $('<input type="search">'),
$button = $('<button>Search</button>'),
$result_container = $('<div id="app_search_result" />'),
$app_list = $('#apps');
var $app_form = $(this).after($search, $button, $result_container).detach();
$search.data('search_context', 'local');