Hi there
Either you're using a *really* old version of Thinking Sphinx (ie: about 3
years old), or you've just been reading really old documentation. The index
definition should look more like this:
define_index do
indexes status
indexes buyer_notes
indexes rsm
indexes [customer.first_name, customer.middle_name, customer.last_name],
:as => :customer_full_name
indexes [items.ship_to_first_name, items.ship_to_middle_name,
items.ship_to_last_name], :as => :ship_to_full_name
indexes items.ship_to_company, :as => :ship_to_company
indexes items.ship_to_state, :as => :ship_to_state
has store_order_id
has store_id
has customer.store_customer_id, :as => :store_customer_id
end
You'll notice here I've separated the obviously non-text data into attributes
(the 'has' method), while I've kept everything else as fields. This is far
better for doing exact integer matches on integers, instead of relying on
Sphinx's text matching algorithms - which are built with a different purpose in
mind.
With all this changed, then your search request becomes the following:
Order.search(
:with => {:store_order_id => 2100, :store_id => 1047},
:include => [:customer, :items, :batch],
:per_page => 10
)
You'll see here that :conditions has become :with - this is because :with is
for attribute filters, whereas :conditions is for searching on specific fields.
If that's not too clear, have a read of the following documentation:
http://freelancing-god.github.com/ts/en/sphinx_basics.html
And if you are using a really old version of Thinking Sphinx, I highly
recommend upgrading to something recent - 1.4.0 for Rails 1.2 or Rails 2, or
2.0.0 for Rails 3.0.0 and 2.0.1 for Rails 3.0.3.
Hopefully this helps a bit :)
Cheers
--
Pat
On 15/12/2010, at 4:19 PM, raghu wrote:
> Hi,
>
> I am having problem in searching the results.
> If the foreign key store_id in the orders table is greater than
> 999, then returns the empty results. But it returns the correct result
> set
> when the its <=999.
>
> How to make it working when the store_id is greater than 999?
>
> Indexes of the order model
>
> class Order < ActiveRecord::Base
>
> define_index do |index|
> index.includes.store_order_id
> index.includes.status
> index.includes.buyer_notes
> index.includes.rsm
> index.includes.store_id
> index.includes.customer.store_customer_id
>
> index.includes.customer(:first_name,:middle_name,:last_name).as.customer_full_name
>
> index.includes.items(:ship_to_first_name,:ship_to_middle_name,:ship_to_last_name).as.ship_to_full_name
> index.includes.items.ship_to_company
> index.includes.items.ship_to_state
> end
>
> end
>
>
>
> Search Query
>
> orders = Order.search(:conditions => {store_order_id=>2100, :store_id
> => 1047}, :include => [:customer,:items,:batch], :per_page => 10)
>
>
>
> --
> 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.
>
--
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.