# Thinking\_sphinx set weighting

**URL:** <https://www.ruby-forum.com/t/thinking-sphinx-set-weighting/150708>\
**Category:** Rails\
**Created:** [October 11, 2008, 9:09pm UTC](https://www.ruby-forum.com/t/thinking-sphinx-set-weighting/150708 "2008-10-11T21:09:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkbeili](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7bcc69/32.png) [@tkbeili](https://www.ruby-forum.com/u/tkbeili)\
**Post date:** [October 11, 2008, 9:09pm UTC](https://www.ruby-forum.com/t/thinking-sphinx-set-weighting/150708/1 "2008-10-11T21:09:58Z")

</div>

Hello,

I’m using Sphinx search engine with thinking\_sphinx Ruby on Rails plugin  
to interface with it. I use it as follows:  
@topics = Topic.search(@search\_phrase,  
:sphinx =\> {:limit =\> $SEARCH\_TOPICS\_PAGE\_COUNT, :page =\>  
@page,:weights =\> [100,60,20,20,10]},  
:per\_page =\> $SEARCH\_TOPICS\_PAGE\_COUNT, :page =\> @page)

with indexing code in side topic.rb:  
define\_index do  
indexes title, description  
indexes comment.description, :as =\> :comment\_description  
indexes poll.poll\_question, :as =\> :poll\_question  
indexes categories.name, :as =\> :category\_name

```
has created_at,rating_score

```

end

it works fine except for weighting! I assume it should give title a  
weight of 100 as it’s first description 60 and so on…

When I search it returns good results but it doesn’t sort it very well  
according to weighting! so if I have a keyword that exist in one topics  
title and another topics comment I want the one with the keyword in the  
title to show first. I might be setting the weights in wrong way? any  
ideas?

Thanks,

Tam
