Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'solrizer-3'

  • Loading branch information...
commit 39ea3c11d351a0472129be73cc39e138e05bc8b7 2 parents 377d093 + 72624ca
@jcoyne jcoyne authored
View
9 lib/solrizer/default_descriptors.rb
@@ -36,7 +36,7 @@ def self.symbol
# Produces _si suffix
def self.sortable
- @sortable ||= Descriptor.new(:string, :indexed)
+ @sortable ||= Descriptor.new(sortable_field_definition, converter: searchable_converter, requires_type: true)
end
# Fields that are both stored and sortable
@@ -78,6 +78,13 @@ def self.stored_searchable_field_definition
end
end
+ def self.sortable_field_definition
+ lambda do |type|
+ vals = [type, :indexed]
+ vals
+ end
+ end
+
def self.searchable_converter
lambda do |type|
case type
View
2  lib/solrizer/field_mapper.rb
@@ -127,7 +127,7 @@ def solr_name(field_name, *opts)
elsif opts.empty?
[:stored_searchable, {type: :text}]
else
- [opts[0], opts[1] || {}]
+ [opts[0], opts[1] || {type: :string}]
end
indexer(index_type).name_and_converter(field_name, args).first
View
10 spec/units/common_spec.rb
@@ -15,13 +15,19 @@ class Foo
Foo.create_and_insert_terms('my_name', 'value', [:displayable, :searchable, :sortable], solr_doc)
solr_doc.should == {'my_name_ssm' => ['value'], 'my_name_si' => ['value'], 'my_name_teim' => ['value']}
end
-
+
it "should handle dates that are searchable" do
solr_doc = {}
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:stored_searchable], solr_doc)
solr_doc.should == {'my_name_dtsim' => ['2013-01-10T00:00:00Z']}
end
+ it "should handle dates that are stored_sortable" do
+ solr_doc = {}
+ Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:stored_sortable], solr_doc)
+ solr_doc.should == {'my_name_dtsi' => ['2013-01-10T00:00:00Z']}
+ end
+
it "should handle dates that are displayable" do
solr_doc = {}
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:displayable], solr_doc)
@@ -31,6 +37,6 @@ class Foo
it "should handle dates that are sortable" do
solr_doc = {}
Foo.create_and_insert_terms('my_name', Date.parse('2013-01-10'), [:sortable], solr_doc)
- solr_doc.should == {'my_name_si' => ['2013-01-10']}
+ solr_doc.should == {'my_name_dti' => ['2013-01-10T00:00:00Z']}
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.