2

If I try to use order_by on a text field I get: "no field configured with name title".

Works fine on fields of type "string". So I end up using a workaround like:

searchable do 
  text :title

  string :title_sortable do 
    title
  end
end

Is there any reason why we cannot order_by on text fields?

4

1 に答える 1

3

This is by Solr design. Text fields are tokenized. Sorting on a tokenized field does not make sense.

Consider the following two white space tokenized fields in two different docs.

"quick fire ammo" "black bear"

When you sort them in ascending order, the first one should not appear before the second, just because it has the word "ammo" in it.

That is why, the sortable fields should be defined as String.

于 2012-07-07T13:31:01.107 に答える