Complex (?!) query raise Errno::ECONNRESET

151 views
Skip to first unread message

El Matou

unread,
Apr 27, 2011, 12:52:35 PM4/27/11
to Sunspot
Hi there,
Facing a problem I couldn't understand (at end of this post) I get a
tiny question to this noble assemblee

Long story short :
Did the query is limited by the lengh of an http request ?
Is there a workaround to this matter ?


For people loving breathless novels, my first issue was :

I'm facing a problem with sunspot/rails when querying a "fairly"
simple search which raise Errno::ECONNRESET (Connection reset by peer)

my setup is :
class Depense < ActiveRecord::Base
...
searchable do
text :motif, :default_boost => 2
text :categorie
string :motif
string :categorie

date :date

integer :user_id
string :imputable_type
integer :imputable_id
integer :id
end
end

My request is :
class DepensesController < ApplicationController
... some code sets @exercice to a range of date #=> Wed, 01 Dec
2010..Fri, 31 Dec 2010 and @imputable to an AR object.

def search
@search = Depense.search(:cancan => [current_ability]) do |query|
query.keywords(params[:term])
if @imputable
query.with(:imputable_type, @imputable.class.name)
query.with(:imputable_id, @imputable.id)
end
query.with(:date, @exercice) if @exercice
query.with(:id,
current_ability.model_adapter(Depense, :read).database_records.collect(&:id))
# an array of ids, may be hughe

query.paginate :page => params[:page] || 1 , :per_page =>
params[:per_page] || 10
query.order_by(:date, :desc)
end
@depenses = @search.results
end
end

A funny thing is, that the same setup works fine on an other class
and second funny thing, the query works also when I comment out one of
the Query#with() statement.

I miss something but what ?! is there a limit of statements in a
search, or a maximal lengh for the hhtp request. (My god I get it
while writing the post...) ?
Reply all
Reply to author
Forward
0 new messages