I’m having problems sorting on untokenized fields. I have one field that
sorts fine, but there are others that seem to sort on a different field.
Here’s the index description:
acts_as_ferret
:remote=>true,:fields=>{:name=>{:boost=>2},:name_for_sort=>{:index =>
:untokenized},
:city=>{:boost=>2}, :city_for_sort=>{:index=>:untokenized},
:state=>{:boost=>2}, :state_for_sort=>{:index=>:untokenized},
:tag_list=>{:boost=>0},:tag_list_for_sort=>{:boost=>0},
:date_summary=>{:boost=>1},
:date_for_range=>{:boost=>0},
:start_date=>{:boost=>0}}
When I sort on name_for_sort it works fine.
City_for_sort however causes problems. Here is a random offset. There
are 16,000 records, so I wouldn’t expect so much disparity:
Event.find_by_contents(“marathon”,:sort=>“city_for_sort”,:offset => 100).map(&:city_for_sort)
=> [“laguna hills”, “burlington”, “buffalo”, “sun valley”, “ottawa”,
“alexandria”, “green bay”, “cleveland”, “aurora denver lakewood”,
“corpus christi”]
and a later batch:
Event.find_by_contents(“marathon”,:sort=>“city_for_sort”,:offset => 400).map(&:city_for_sort)
=> [“ocean shores”, “austin”, “boca raton”, “sauvie island”, “crested
butte”, “austin”, “portland”, “avery”, “leadville”, “houston”]
Notice that name works:
Event.find_by_contents(“marathon”,:sort=>“name_for_sort”,:offset => 400).map(&:name_for_sort)
=> [“Columbus Marathon”, “Columbus Marathon”, “Columbus Marathon”,
“Columbus Marathon”, “Columbus Marathon”, “Columbus Marathon Relay”,
“Columbus Marathon Relay”, “Columbus Marathon Relay”, “Comcast Baltimore
Marathon”, “Comcast Baltimore Marathon”]
Notice however that it appears to be sorting on a range column, even
when we ask for city_for_sort:
Event.find_by_contents(“marathon”,:sort=>“city_for_sort”,:offset => 400).map(&:date_for_range)
=> [“20060709”, “20060708”, “20060708”, “20060704”, “20060704”,
“20060704”, “20060704”, “20060702”, “20060701”, “20060701”]
Does anyone have an idea what could cause this? I’ve rebuild the index
several times and it doesn’t help.
I’ve also noticed that the default field list doesn’t include the
columns:
using index in script/…/config/…/config/…/index/development/event
default field list: [:state, :start_date, :name, :tag_list, :city,
:tag_list_for_sort, :date_for_range, :date_summary]
When I look at ferret-browser, it does show the city_for_sort column. I
can browse the values in order and its parameters match those of
name_for_sort which works.
I’m completely stumped.