If you're using numbers to represent words, I'd recommend shifting ethnicity 
into its own model, and then use an association to bring that data in to your 
index. Also: the primary key is available as an attribute named 
'sphinx_internal_id' - so you don't need to create an attribute called id 
(which is not recommended anyway, as Sphinx may get confused with its own id 
value).

  ThinkingSphinx::Index.define :user, :with => :active_record do
    # fields
    indexes name, :as => :user, :sortable => true
    indexes religion, about_me, sexuality, children, user_smoke, user_drink, 
age, gender
    indexes ethnicity.name, :as => :ethnicity
    # attributes
    has created_at, updated_at
  end

-- 
Pat

On 23/08/2013, at 12:20 PM, C Wilson wrote:

> I am not getting results. The console shows 0
> 
>   Sphinx Query (51.8ms)  SELECT * FROM `user_core` WHERE MATCH('asian 
> @sphinx_internal_class_name (User)') AND sphinx_deleted = 0 LIMIT 0, 20
>   Sphinx  Found 0 results
>  => [] 
> 
> The console does work for "man", I have to change how Sphinx reads my 
> database as I have numbers that represent the options such as 1 for asian, 2 
> for a different ethnicity, etc.
> 
> But even with the console working for gender, it shows 3 results in the 
> console but it doesn't display on server. Still listing all users for keyword 
> "man" when I search when it should only pull 3 users.
> 
> 
> 
> On Friday, August 9, 2013 10:39:10 AM UTC-4, C Wilson wrote:
> I'm a little confused at how to setup in controller to pull the search 
> results. For def index I have:
> 
>       @users = params[:query].blank? ? User.all : User.search(params[:query])
> 
> And that in return pulls all users when performing a search. But I have a 
> dating app so I need it to only pull users that has the data that was search 
> for.
> 
> Even if trying it in console with User.search 'asian' or any other option I 
> get:
> 
> <ThinkingSphinx::Masks::PaginationMask:0x007fe011785ca0 
> @search=#<ThinkingSphinx::Masks::PaginationMask:0x007fe011785ca0 ...>> 
> 
> So I know it's not setup right. Do I need to list conditions for all searches 
> beneath @users? I'm new to rails so this isn't coming to me as good as 
> others. And there's really no examples at how to setup in controller. 
> 
> -- 
> 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 http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/groups/opt_out.
> <Screen Shot 2013-08-22 at 10.10.54 PM.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 http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to