Hey Guys,

This is what i ended up with... doesn't work as nice as my mysql
one... but is 10 times faster :)

The problem with this is a @weight of 1 will go before something on
the same format with a @weight of 0 (what I was trying to avoid by
using fullscan)

products = Product.search @similar_keywords,
  :with => {:oflc_id => @similar_oflcs.uniq, :genre_id =>
@similar_genres.uniq},
  :without => {:id => @similar_ids},
  :match_mode => :any,
  :sort_mode => :expr,
  :order => "@weight/4 +
IF(IN(product_format_id,#{@similar_formats.uniq.join(',')}),4,0) +
(available_on / 4294967292)",
  :per_page => 15

still_needed = 27 - products.size

if still_needed > 0

  ignore_ids = @similar_ids
  products.each do |p|
    ignore_ids << p.id
  end

  products_extra = Product.search :with => {:oflc_id =>
@similar_oflcs.uniq, :genre_id => @similar_genres.uniq},
    :without => {:id => ignore_ids},
    :sort_mode => :expr,
    :order =>
"IN(product_format_id,#{@similar_formats.uniq.join(',')}) +
(available_on / 4294967292)",
    :per_page => still_needed
  puts products_extra.size
  products_extra.each do |p|
    products << p
  end

end

Thanks,
David Bennett.

On Jun 27, 5:47 pm, complistic <[email protected]> wrote:
> Hey Pat,
>
> Thanks for getting back to me :)
>
> > The first part: 'matches query' - would indicate what you're trying is 
> > valid. But the rest: 'any query terms will be ignored ... no text-matching' 
> > - would suggest that the search query is being ignored, and only filters, 
> > grouping and sorting come into play.
>
> Thats what im trying to do! I only want to use the keywords for
> sorting.
>
> I did some snooping and notice that when i use the :fullscan option,
> the socket thats returned is blank!
> (riddle (1.3.3) lib/riddle/client.rb:640:in `request')
>
> Anyway,
> I'm going to try the approach mentioned 
> here:http://sphinxsearch.com/forum/view.html?id=4155
> Doing an :any + a :fullscan without keywords and then joining them.
>
> I'll post my results :)
>
> Thanks Again,
> David Bennett.
>
> On Jun 26, 4:05 pm, Pat Allan <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi David
>
> > Sorry I've not gotten back to you sooner on this issue.
>
> > I think it may be related to the fullscan match mode - I'm not certain, but 
> > I think queries are ignored. The docs aren't particularly clear:
>
> > > SPH_MATCH_FULLSCAN, matches query, forcibly using the "full scan" mode as 
> > > below. NB, any query terms will be ignored, such that filters, 
> > > filter-ranges and grouping will still be applied, but no text-matching.
>
> > The first part: 'matches query' - would indicate what you're trying is 
> > valid. But the rest: 'any query terms will be ignored ... no text-matching' 
> > - would suggest that the search query is being ignored, and only filters, 
> > grouping and sorting come into play.
>
> > Maybe it's worth hunting around on the Sphinx forum for confirmation?
>
> > --
> > Pat
>
> > On 17/06/2011, at 1:57 PM, complistic wrote:
>
> > > Spoke to soon!
>
> > > This also happens on my production server :( just it was able to match
> > > more products with the keywords i was looking for (due to stops).
>
> > > Does anyone know how I can check to make sure :fullscan is being sent
> > > to sphinx.
>
> > > Also, is there a command line option for fullscan?
>
> > > Thanks,
> > > David Bennett.
>
> > > On Jun 17, 12:11 pm, complistic <[email protected]> wrote:
> > >> Hey,
>
> > >> Just an update...
>
> > >> This only happens on my development server :O  ...all works fine on my
> > >> production server.
>
> > >> So I'm guessing its something sphinx or environment related.
>
> > >> development:
> > >>  ubuntu Natty
> > >>  sphinx: 2.0.1-beta (from source)
> > >> production:
> > >>  debian Squeeze
> > >>  sphinx: 2.0.1-beta (from source)
>
> > >> Thanks,
> > >> David Bennett
>
> > >> On Jun 16, 10:27 pm, complistic <[email protected]> wrote:
>
> > >>> Hey guys,
>
> > >>> I've been using Thinking Sphinx for a wile now and find it great!
>
> > >>> ...but today I'm trying to select "similar products" using the
> > >>> fullscan option but it seems to have not effect at all!
>
> > >>> my code:
>
> > >>> products = Product.search @similar_keywords,
> > >>>       :with => {:oflc_id => @similar_oflcs.uniq, :genre_id =>
> > >>> @similar_genres.uniq},
> > >>>       :without => {:id => @similar_ids},
> > >>>       :matchmode => :fullscan,
> > >>>       :sort_mode => :expr,
> > >>>       :order => "@weight +
> > >>> IN(product_format_id,#{@similar_formats.uniq.join(',')}) +
> > >>> (available_on / 4294967292)",
> > >>>       :per_page => 27
>
> > >>> Basicly that returns products that match the keywords, so removing
> > >>> fullscan has no effect.
>
> > >>> If I remove the @similar_keywords, the function will return all the
> > >>> results as expected (without the weight).. so this one has be stumped.
>
> > >>> Thanks,
> > >>> David.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Thinking Sphinx" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to 
> > > [email protected].
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/thinking-sphinx?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to