Hi Frank

There’s a couple of ways to approach what you’re trying to do, and the right 
one depends on how you’re expecting people to use your search functionality.

Is “@org_unit_id 1” something you’re expecting your users to enter in a search 
text field? If so, using a field (the indexes method) is a good idea (though 
the type option is irrelevant - all fields are strings, they can’t be anything 
else). What you’re missing is setting the match mode to :extended:

  ThinkingSphinx.search ‘@org_unit_id 1’, :classes => [RxBrand, 
ProviderSearchGroup], :match_mode => :extended

However, if this id value comes from a select box, or more deeply within your 
code as opposed to being a user-provided value, then it’s probably better 
handled as an attribute - and thus, stored as an integer:

  # in your index definition
  has org_unit_provider_service_groups.org_unit_id

  # in your search
  ThinkingSphinx.search :with => {:org_unit_id => 1}, :classes => [RxBrand, 
ProviderSearchGroup]

Fields should generally be focused on text values that users are going to 
search upon, whereas attributes are best suited to ordering and filtering 
results. There’s a bit more detail on this on  the Thinking Sphinx website:
http://pat.github.io/thinking-sphinx/sphinx_basics.html

Cheers

— 
Pat

On 7 Dec 2013, at 6:39 am, Frank Kany <[email protected]> wrote:

> Good afternoon,
> 
> I've been working on this issue for the last 2 days and cannot solve it.
> 
> In my Rails console, when I run this simple query, I'm expecting results to 
> be returned:
> 
> ThinkingSphinx.search "@org_unit_id 1", :classes => 
> [RxBrand,ProviderServiceGroup]
> 
> Data exists in the MySQL tables.
> 
> Here's the index:
> 
>           define_index do
> 
>             indexes :name
> 
>             indexes :description
> 
>             indexes :extra_terms # bonus words for this drug, not otherwise 
> visible
> 
>             indexes provider_service_codes.service_code, :as => :service_codes
> 
>             indexes provider_service_codes.common_description, :as => 
> :service_code_description
> 
>             indexes org_unit_provider_service_groups.org_unit_id, :type => 
> :string, :as => :org_unit_id
> 
> 
> 
>             where 'searchable = 1'
> 
>             set_property :group_concat_max_len => 65535
> 
> 
> 
>             # default field_weight is 1 for unmentioned fields. This is used 
> when ranking search results
> 
>             set_property :field_weights => { :name => 2, :extra_terms => 10 }
> 
>             set_property :delta => ThinkingSphinx::Deltas::ResqueDelta
> 
> 
> 
>             # explicit group by
> 
>             group_by 'name, description, extra_terms, org_unit_id'
> 
>           end
> 
> 
> 
> What could I be doing wrong?  Any help is appreciated.
> 
> Thanks,
> 
> Frank
> 
> 
> -- 
> 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.

-- 
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