Home Search with boolean true using thinking sphinx is not working properly, when boolean is false also its showing results
Reply: 1

Search with boolean true using thinking sphinx is not working properly, when boolean is false also its showing results

Mahantesh D
1#
Mahantesh D Published in 2018-02-14 05:49:37Z

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
razvans
2#
razvans Reply to 2018-02-14 11:42:29Z

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 }) 
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.324669 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO