Hi Alan

There's a lot to take in there, but I think the core of the issue you're 
currently facing comes down to the fact that you're using a string attribute, 
and Sphinx doesn't let you filter by attributes (:conditions is for fields, 
:with is for attributes). There's a note buried in the docs about this:
http://pat.github.com/ts/en/common_issues.html#string_filters

I would probably recommend switching days to be field instead, and just use 
conditions.

Let me know how it goes and whether there's further questions.

Cheers

-- 
Pat


On 01/02/2013, at 12:49 PM, Alan DeLonga wrote:

> Hey Pat,
> 
> I have been wrestling with an outsourced project that they brought back in 
> house. They used Thinking Sphinx, without giving any documentation or 
> comments in their code about how they set things up or what they were trying 
> to achieve. After months of hacking away at this app, its 95% finished. The 
> last part I am having difficulty fixing is getting the search to constrain 
> the results correctly. I am super new to this and would appreciate any 
> insight you could give me. So here is my issue on stackoverflow, and I will 
> elaborate below as well.
> 
> So basically the issue is between 3 models/tables users, bars and 
> bar_profiles. There are bar_profiles for each bar, that contains the criteria 
> we are matching against the users criteria. There is a bar_profile for each 
> day, containing the criteria to match against for the users selections.
> 
> Inside bar is where the search is happening so they set up indexes for 
> bar_profiles as follows:
> 
> has_many :bar_profiles
> 
> define_index do
> 
>     has bar_profiles
> (:day), :as => :
> days
>     indexes bar_profiles
> .budget, :as => :budget_tags
>     indexes bar_profiles.day, :as => :
> day
>     indexes bar_profiles
> .tags, :as => :daily_tags
>     .
> 
>     
> .
> 
>   
> end
> 
> and in the method that runs the search I have:
> 
>     today = ((Time.now + Time.zone_offset('EST')).strftime("%A")).downcase
>     search_options = {:conditions => {}, :with => {:days=>today}, :page => 1, 
> :per_page => algorithm.results_per_page}
> 
>     search_options[:conditions][:experience_tags] = options[:experience] 
> unless options[:experience].blank?
>     budget = combine_budgets(options[:budget])
>     search_options[:conditions][:budget_tags] = budget unless budget.blank? 
> 
> What I am trying to do is match the options[...] that the user selects 
> against the bar_profile that matches up with the current day. The current set 
> up allows the search to run without errors using:
> 
> bars = Bar.search(search_options)
> 
> But when I added in the :with=> {:days=>today}, I stopped getting any results 
> back from the search. So I am guessing I just don't fully understand how to 
> use 'with' in Thinking Sphinx for my exact implementation. What I am trying 
> to do is make the search constrain the results based on the current day.
> 
> Where my goal would be if I don't pass in any conditions, it would return all 
> the bars with a profile for today. If I have a condition for budget_tag = low 
> budget, I only want to get back bars that have a bar_profile for today that 
> contains that budget_tag.
> 
> Currently without the 'with' option it will return any bar that has ANY 
> bar_profile that has one of the match criteria. So I am getting a bar that 
> has the criteria, but for the wrong day.
> 
> If you could help guide me to some examples or give some insight I would 
> really appreciate it. I have been wrestling with this issue for a week now 
> and I have gotten to this point but still can't seem to get the functionality 
> I need. I know I am doing something wrong, I just don't really understand how 
> to correct it. Either way I appreciate you taking the time to read this.
> 
> Thanks,
> 
> Alan
> 
> 
> -- 
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to