controller:
> @distance = params[:distance].to_i || 25
> @lng = params[:longitude].to_f
> @lat = params[:latitude].to_f
> @limit = params[:limit].to_f || 15
>
>
> @tag = Tag.find(2)
> @tag2 = Tag.find(3)
>
> promo_stores_nearby = PromoStore.near({
> :distance => @distance,
> :limit => 10000,
> :coordinates => "#{@lat}, #{@lng}",
> })
>
>
> query = "\"#{search_terms.join("\"|\"")}\""
>
> promostocks =
> PromoStock.inpromostore(promo_stores_nearby).uniq_by_price_per_unit.filter_by_tag_amount(@tag).search(query)
> promo_stores_that_have_first_tag = promostocks.collect(&:promo_store)
>
> promostocks2 =
> PromoStock.inpromostore(promo_stores_that_have_first_tag).uniq_by_price_per_unit.filter_by_tag_amount(@tag2).search(query2)
> promo_stores_that_have_both_tags = promostocks2.collect(&:promo_store)
>
All variables before promostock2 are same in both console and in web/rake.
models/promo_stock.py:
> define_index do
> indexes coupon.description, :as => :name
> indexes coupon.additional_info, :as => :description
> indexes coupon.brand.name, :as => :brand
> indexes coupon_id, :as => :coupon, :facet => true
> indexes coupon.amount_unit, :as => :coupon_amount_unit
> indexes promo_store.name, :as => :promo_store_name, :facet => true
> indexes coupon.standard_size_unit, :as => :size_unit, :facet => true
>
> has coupon_id, promo_store_id
> has coupon.price_per_unit, :as => :price_per_unit
> has coupon.standard_size, :as => :size
> end
>
>
> sphinx_scope(:uniq_by_price_per_unit) do
> {
> :group_by => 'promo_store_name_facet',
> :group_function => :attr,
> :match_mode => :extended,
> :group_clause => "price_per_unit ASC, @relevance DESC",
> :order => "price_per_unit ASC, @relevance DESC",
> :retry_stale => true,
> }
> end
>
>
> sphinx_scope(:inpromostore) do |stores|
> in_stores = "*, IN(promo_store_id, #{stores.collect(&:id).join(', ')}) AS
> instore"
> unless in_stores.empty?
> {
> :sphinx_select => in_stores,
> :with => {'instore' => 1},
> :retry_stale => true,
> }
> else
> {}
> end
> end
>
>
> sphinx_scope(:filter_by_tag_amount) do |tag|
> unless tag.amount.nil?
> percent = 0.10
> min_amount = 0
> max_amount = 99999
> min_amount = tag.amount * (1 - percent)
> max_amount = tag.amount * (1 + percent)
> {
> :with => {:size => min_amount..max_amount, :size_unit_facet =>
> tag.amount_unit.to_crc32}
> }
> else
> {}
> end
> end
>
On Saturday, February 23, 2013 at 6:19 AM, Pat Allan wrote:
> Could you show us the search code that you're running? I'm not really sure
> what could be causing this… it's certainly not an easy thing to debug.
>
> On 22/02/2013, at 5:05 AM, Stas Pisockij wrote:
>
> > The values that are used are models instead. While debugging. I tracked
> > each line and all data is identical except for the final result.
> >
> > Basically what I'm doing is I'm getting some results from ThinkingSphinx
> > search, then use that in next ThinkingSphinx search and this is where the
> > data differs comparing to console.
> >
> > By the way. I've seen this problem occurs not only in passenger, but in
> > WEBrick, rake and others.
> > I've tried disabling classes caching:
> > config.cache_classes = false
> > config.consider_all_requests_local = false
> > config.action_controller.perform_caching = false
> > config.reload_classes_only_on_change = false
> >
> > I've also read other threads and no, I'm not using subclasses and I tried
> >
> > :populate => true - does not help
> > :retry_stale => true - does not help
> >
> > I'm trying to search within millions of rows of data, could that be a
> > problem?
> > Can it be max_matches thing?
> >
> > Any other suggestions?
> > On Thursday, February 21, 2013 at 3:48 PM, Declan Frye wrote:
> >
> > > This is a stab in the dark, but is it possible there's a value that
> > > you're typing in as an integer in the console but that is actually being
> > > passed as a string in the controller? Maybe something from the params
> > > hash? That's definitely tripped me up before.
> > >
> > > Declan
> > >
> > > On Feb 20, 2013 7:19 PM, "Stanislav Pisockij" <[email protected]
> > > (mailto:[email protected])> wrote:
> > > > Hi guys,
> > > >
> > > > I'm having a same issue. When I try to execute a search in rails
> > > > console it brings results, when I'm trying to do same in controller it
> > > > does not. But if in controller I change the condition I get results. So
> > > > it seems like it's working but partially.
> > > > eg.
> > > > Search('abc').filter(...) returns 0 results in passanger and 10 in
> > > > console
> > > > Search('abc') returns 500 results in passanger and 500 in console
> > > >
> > > > I'm running:
> > > >
> > > > Apache/2.2.22 (Ubuntu)
> > > > Phusion Passenger version 3.0.17
> > > > Sphinx 2.0.4-release (r3135)
> > > >
> > > > thinking-sphinx (2.0.13)
> > > > riddle (1.5.3)
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Thinking Sphinx" group.
> > > > To unsubscribe from this group and stop receiving emails from it, send
> > > > an email to [email protected]
> > > > (mailto:[email protected]).
> > > > To post to this group, send email to [email protected]
> > > > (mailto:[email protected]).
> > > > Visit this group at
> > > > http://groups.google.com/group/thinking-sphinx?hl=en.
> > > > For more options, visit https://groups.google.com/groups/opt_out.
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Thinking Sphinx" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an
> > > email to [email protected]
> > > (mailto:[email protected]).
> > > To post to this group, send email to [email protected]
> > > (mailto:[email protected]).
> > > Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> > > For more options, visit https://groups.google.com/groups/opt_out.
> > >
> > >
> > >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Thinking Sphinx" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected]
> > (mailto:[email protected]).
> > To post to this group, send email to [email protected]
> > (mailto:[email protected]).
> > Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> >
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> (mailto:[email protected]).
> To post to this group, send email to [email protected]
> (mailto:[email protected]).
> Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.