Another web app using Ferret

I am apart of a team that runs a student site called Studicious
(http://stu.dicio.us). We have been using Ferret from the beginning, and
recently added acts_as_ferret and sorting to the system.

As you can see if you try the search, sorting is not working as
expected. I am using this code (w/ find_by_content):

:sort => Ferret::Search::SortField.new(:school_sort, :reverse => false)

:school_sort is an untokenized field with otherwise default settings.
Any ideas?

  • Winton

On 10/2/06, Winton [email protected] wrote:

Any ideas?

  • Winton

Hi Winton,

Sorry for the slow reply. Is it possible that one of your schools
begins with a number? numbers appear in the database before letters so
when Ferret detects the fields type it may think the field is an
integer field. For example, imagine you are indexing tv shows. “24”
would probably be the first entry in the index so when you try to sort
by that field it will think it is an integer. So you need to specify
that the field is in fact a string field.

:sort => Ferret::Search::SortField.new(:school_sort, :type => :string,
:reverse => false)

I hope that helps, otherwise it really looks to me like the field is
tokenized. I’d check that again just in case.

Cheers,
Dave

PS: love the site design

Would there be any way for it to still be tokenized when defining it as

‘school_sort’ => { :index => :untokenized }

in the model (a_a_f)? I just saw the other thread on sorting strangeness
and it seems like I am having similar problems. I will try that solution
and get back.

Thanks again for a great library.

  • Winton

David B. wrote:

On 10/2/06, Winton [email protected] wrote:

Any ideas?

  • Winton

Hi Winton,

Sorry for the slow reply. Is it possible that one of your schools
begins with a number? numbers appear in the database before letters so
when Ferret detects the fields type it may think the field is an
integer field. For example, imagine you are indexing tv shows. “24”
would probably be the first entry in the index so when you try to sort
by that field it will think it is an integer. So you need to specify
that the field is in fact a string field.

:sort => Ferret::Search::SortField.new(:school_sort, :type => :string,
:reverse => false)

I hope that helps, otherwise it really looks to me like the field is
tokenized. I’d check that again just in case.

Cheers,
Dave

PS: love the site design

(PS - Sorry, I didn’t address your solution. Even with :type => :string
I am getting odd sorting.)

On 10/5/06, Winton [email protected] wrote:

  • Winton
    Hi Winton,

If the index was already created before you defined the field as
untokenized then it would remain tokenized. You can check like this:

puts index.field_infos

That will print a YAML output of your field infos.

Cheers,
Dave

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs