-
Notifications
You must be signed in to change notification settings - Fork 13
Using Solrizer 3.0.0 _ALPHA_
ndushay edited this page Jan 28, 2013
·
6 revisions
Solrizer 3.0 is currently in pre-release, it is not the current API
solr_doc = {}
Solrizer.insert_field(solr_doc, 'title', 'whatever', :searchable)
=> {"title_tesim"=>["whatever"]}
Solrizer.insert_field(solr_doc, 'pub_date', 'Nov 2012', :sortable, :displayable)
=> {"title_tesim"=>["whatever"], "pub_date_ssi"=>["Nov 2012"], "pub_date_ssm"=>["Nov 2012"]}
# as a date
solr_doc = {}
Solrizer.insert_field(solr_doc, 'pub_date', Date.parse('Nov 7th 2012'), :searchable)
=> {"pub_date_dtsi"=>["2012-11-07T00:00:00Z"]}
# or as a string
solr_doc = {}
Solrizer.insert_field(solr_doc, 'pub_date', Date.parse('Nov 7th 2012'), :sortable, :displayable)
{"pub_date_ssi"=>["2012-11-07"], "pub_date_ssm"=>["2012-11-07"]}
# or a string that is stored as a date
solr_doc = {}
Solrizer.insert_field(solr_doc, 'pub_date', 'Jan 29th 2013', :dateable)
=> {"pub_date_dtsi"=>["2013-01-29T00:00:00Z"]}
All you have to do is create your own index descriptor:
solr_doc = {}
displearchable = Solrizer::Descriptor.new(:integer, :indexed, :stored)
Solrizer.insert_field(solr_doc, 'some_count', 45, displearchable)
{"some_count_isi"=>["45"]}
Simply override the methods within Solrizer::DefaultDescriptors
# before
solr_doc = {}
Solrizer.insert_field(solr_doc, 'title', 'foobar', :facetable)
=> {"title_sim"=>["foobar"]}
# redefine facetable:
module Solrizer
module DefaultDescriptors
def self.facetable
Descriptor.new(:string, :indexed, :stored)
end
end
end
# after
solr_doc = {}
Solrizer.insert_field(solr_doc, 'title', 'foobar', :facetable)
=> {"title_ssi"=>["foobar"]}
module MyMappers
def self.mapper_one
Solrizer::Descriptor.new(:string, :indexed, :stored)
end
end
solr_doc = {}
Solrizer::FieldMapper.descriptors = [MyMappers]
=> [MyMappers]
Solrizer.insert_field(solr_doc, 'title', 'foobar', :mapper_one)
=> {"title_ssi"=>["foobar"]}
Same as it ever was:
t.main_title(:index_as=>[:facetable],:path=>"title", :label=>"title") { ... }
But now you may also pass an Descriptor instance if that works for you:
indexer = Solrizer::Descriptor.new(:integer, :indexed, :stored)
t.main_title(:index_as=>[indexer],:path=>"title", :label=>"title") { ... }