Hi Terence
A few things to try:
* Can you update to the latest Thinking Sphinx code (from the develop branch in
the GitHub repo):
gem ‘thinking-sphinx’, ‘~> 3.2.0’,
:git => ‘git://github.com/pat/thinking-sphinx.git'
<git://github.com/pat/thinking-sphinx.git'>,
:branch => ‘develop’
:ref => ‘cf16d18285'
* Once you’ve updated, can you run ts:regenerate and see if that helps?
* Are you mixing SQL-backed indices and real-time indices? I’d recommend only
using one or the other.
* If none of this helps, can you try running `rake ts:stop`, then delete the
db/sphinx and tmp/binlog directories, then `rake ts:regenerate` again?
* Which version of Sphinx are you using?
Unrelated to your problem, but the match_mode and sort_mode arguments are not
used in index definitions. The sort_mode argument only applies in search calls,
and match_mode was only for search calls in TS v1/v2. v3 uses the SphinxQL
protocol (as you can see in the logs - it’s very similar to SQL), and that
always uses the extended match mode.
Cheers
—
Pat
> On 7 Sep 2016, at 1:40 PM, Terence Leong <[email protected]> wrote:
>
> Hello, recently I have just started using sphinx and thinking sphinx on rails
> 5.0. I have created a project to test it out.
> SQL backed index worked fine however I faced many problems when I switched to
> real time index.
> The first screen shot shows that the wildcard query returns me all the
> objects in the index while the second screen shot returns me duplicated
> results of the same object.
> The third screen shot shows that it returned the results I wanted. These are
> my code please advise.
>
> index controller:
> @results = ThinkingSphinx.search(
> "#{params[:search]}*",
> :select => '*, weight() as w', :classes => [Provider, Source,
> Rechargeable, SimSize, PocketWifi], :order => 'w DESC'
> )
>
> ThinkingSphinx::Index.define :provider, :with => :real_time do
> # fields
> indexes provider_name, :sortable => true, :match_mode => :any, :sort_mode
> => :desc
> indexes provider_country, :sortable => true, :match_mode => :any,
> :sort_mode => :desc
> indexes source_info, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
>
> set_property :enable_star => 1 #enables wildcard
> set_property :min_infix_len => 2 #define wildcard query length
>
> ThinkingSphinx::Index.define :Source, :with => :real_time do
> # fields
> indexes plan_name, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes max_speed, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes price, :sortable => true, :match_mode => :any, :sort_mode => :desc
> indexes remark, :sortable => true, :match_mode => :any, :sort_mode => :desc
> indexes tethering, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes where_to_buy, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes sim_disposal, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes fair_usage, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes activation, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes comm_standard, :sortable => true, :match_mode => :any, :sort_mode
> => :desc
> indexes plan_quota, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes plan_day, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes simsize_info, :sortable => true, :match_mode => :any, :sort_mode =>
> :desc
> indexes rechargeable_info, :sortable => true, :match_mode => :any,
> :sort_mode => :desc
> indexes pocketwifi_info, :sortable => true, :match_mode => :any, :sort_mode
> => :desc
>
> set_property :enable_star => 1 #enables wildcard
> set_property :min_infix_len => 2 #define wildcard query length
>
> class Provider < ApplicationRecord
> has_many :Source
> after_save ThinkingSphinx::RealTime.callback_for(:Provider)
>
> def source_info
> Source.pluck(:plan_name, :max_speed, :price, :remark, :tethering,
> :where_to_buy, :sim_disposal, :fair_usage, :activation, :comm_standard,
> :plan_quota, :plan_day).join(' ')
> end
> end
>
> class Source < ApplicationRecord
> belongs_to :Provider
> has_many :SimSize
> has_many :Rechargeable
> has_many :PocketWifi
> after_save ThinkingSphinx::RealTime.callback_for(:Source)
>
> def simsize_info
> SimSize.pluck(:sim_name, :sim_type).join(' ')
> end
>
> def rechargeable_info
> Rechargeable.pluck(:recharge_quota, :recharge_price,
> :recharge_desc).join(' ')
> end
>
> def pocketwifi_info
> PocketWifi.pluck(:number_of_user, :origin_country,
> :destination_country).join(' ')
> end
> end
>
>
> --
> 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 https://groups.google.com/group/thinking-sphinx
> <https://groups.google.com/group/thinking-sphinx>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
> <Screenshot from 2016-09-07 11:28:24.png><Screenshot from 2016-09-07
> 11:29:04.png><Screenshot from 2016-09-07 11:30:32.png>
--
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 https://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.