Hi Lonnie
I'm afraid what you're after isn't possible with *Sphinx*, rather than Thinking
Sphinx - though is an easy enough work-around. Firstly: Thinking Sphinx doesn't
use field weight defaults when you're searching across multiple models, and
part of that is the complexity of combining field weights in the expected
manner, but also: when you're querying across multiple indices, Sphinx doesn't
distinguish between fields from each - there's no equivalent of a SQL database
approach (companies.name vs brands.name).
So, the workaround: the fields need to have different names, and you'll need to
specify the weights when searching.
Hope this helps.
--
Pat
On 09/02/2013, at 7:13 AM, Lonnie Warpup wrote:
> I am having difficulties with multiple indexes defined on different models,
> but with different field_weights. For example:
>
> brand_index.rb
> ThinkingSphinx::Index.define :brand, :with => :active_record do
> indexes :name
>
> set_property :field_weights => {
> :name => 5
> }
> end
>
> company_index.rb
> ThinkingSphinx::Index.define :company, :with => :active_record do
> indexes :name
>
> set_property :field_weights => {
> :name => 10
> }
> end
>
> When I execute the following query, I don't see any reference to the field
> weights and I'm always getting Brand records first.
>
> ThinkingSphinx.search('sometext', :indices => %w[brand_core company_core])
> => SELECT * FROM `brand_core`, `company_core` WHERE MATCH('sometext') AND
> sphinx_deleted = 0 LIMIT 0, 20
>
> However if I explicitly add the field weights to the search command I do see
> them. This however doesn't help me with different models having different
> weights.
>
> ThinkingSphinx.search('sometext', :field_weights => { :name => 10 }, :indices
> => %w[brand_core company_core])
> => SELECT * FROM `brand_core`, `company_core` WHERE MATCH('sometext') AND
> sphinx_deleted = 0 LIMIT 0, 20 OPTION field_weights=(name=10)
>
> Is this no longer possible in the 3.x gem, or am I doing something wrong?
>
> Thanks.
> -Lonnie
>
> --
> 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.