0

this is code in my indices file

ThinkingSphinx::Index.define 'cg_user/user', :name => 'reviewer_search', :with => :active_record, :delta => true  do
  indexes profile.interests.interest_name, :as => :interest_name
  has profile(:voluntary_reviewer), as: :profile_voluntary_reviewer, :type=>:boolean
  has id, :as => :user_id
  set_property :field_weights => { :interest_name => 3 }
end

this is my condtion in model

CgUser::User.search(search_string,
                    :with => {:profile_voluntary_reviewer => true, 
                    :user_id => probable_matched_name_ids},
                    :indices => ['reviewer_search_core', 
                    'reviewer_search_delta']
                   ).map(&:id).compact
Community
  • 1
  • 1

1 Answers1

0

Check How to index boolean column in thinking sphinx using Ruby 1.8.7, see if it fixes your issue.

From docs:

Known types for real-time indices are: integer, boolean, string, timestamp, float, bigint and json.

You are using SQL backed indexes and boolean might not work. Try instead with 0 and 1.

Attempt #1

Because you're using SQL backed indices, boolean values are stored in Sphinx same as in your database, 0 and 1.

# index
has profile(:voluntary_reviewer), as: :profile_voluntary_reviewer, type: :integer

# model
CgUser::User.search(search_string, with: { profile_voluntary_reviewer: 1 }) 
razvans
  • 3,172
  • 7
  • 22
  • 30
  • i am setting boolean condition for fields not for indexes. – Mahantesh D Feb 14 '18 at 10:32
  • @MahanteshD It's not talking about the "indexes" macro but the whole 'cg_user/user' index. For SQL backed index, `boolean` for attributes might not work. – razvans Feb 14 '18 at 10:38
  • @MahanteshD Updated the answer to use 0 and 1. Please see if it works. Don't forget to reindex. – razvans Feb 14 '18 at 11:42
  • i tried with integer value with reindex again i am getting same result, no change. is there any way to do? – Mahantesh D Feb 14 '18 at 17:46
  • also when add new interest that time also result is not coming, after rebuilding(reindex) only im getting. plz help me out.. Thank you – Mahantesh D Feb 14 '18 at 17:50
  • @MahanteshD Please update with the sphinx query from your developement.log and the index logs for `reviewer_search_core` (from rake ts:index) AND the result of `CgUser::User.first.profile.voluntary_reviewer` – razvans Feb 14 '18 at 21:40
  • the search is working fine but it takes more time when i change voluntary_reviewer 0 to 1, immediately result are not shown. It takes one hour or two hours to show the result. thank you – Mahantesh D Feb 16 '18 at 12:55
  • @MahanteshD I shouldn't be that slow, I'm at ~ 15 ms tops. – razvans Feb 16 '18 at 13:12