
Security News
Researcher Exposes Zero-Day Clickjacking Vulnerabilities in Major Password Managers
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
A lightweight tool for creating dynamic solr schema sufixes.
The gem is hosted on rubygems.org. The best way to manage the gems for your project is to use bundler. Create a Gemfile in the root of your application and include the following:
source "https://rubygems.org"
gem 'solrizer'
Then:
bundle install
The code snippets in the following sections can be cut/pasted into your console, giving you the opportunity to play with Solrizer.
Start up a console and load solrizer:
> irb
> require "rubygems"
> require "solrizer"
The FieldMapper
maps term names and values to Solr fields, based on the term's data type and any index_as options.
Solrizer comes with default mappings to dynamic field types defined in the Hydra Solr
schema.xml.
More information on the conventions followed for the dynamic solr fields is on the wiki page.
To examine all of Solrizer's field names, open up a ruby console:
> require 'solrizer'
=> true
> default_mapper = Solrizer::FieldMapper.new
=> #<Solrizer::FieldMapper:0x007fb47a273770 @id_field="id">
> default_mapper.solr_name("foo",:searchable, type: :string)
=> "foo_teim"
> default_mapper.solr_name("foo",:searchable, type: :date)
=> "foo_dtim"
> default_mapper.solr_name("foo",:searchable, type: :integer)
=> "foo_iim"
> default_mapper.solr_name("foo",:facetable, type: :string)
=> "foo_sim"
> default_mapper.solr_name("foo",:facetable, type: :integer)
=> "foo_sim"
> default_mapper.solr_name("foo",:sortable, type: :string)
=> "foo_si"
> default_mapper.solr_name("foo",:displayable, type: :string)
=> "foo_ssm"
> solr_doc = Hash.new
> Solrizer.insert_field(solr_doc, 'title', 'whatever', :stored_searchable)
=> {"title_tesim"=>["whatever"]}
> Solrizer.insert_field(solr_doc, 'pub_date', 'Nov 2012', :sortable, :displayable)
=> {"pub_date_si"=>"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_dtim"=>["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_dti"=>"2012-11-07T00:00:00Z", "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_dtsim"=>["2013-01-29T00:00:00Z"]}
> solr_doc = {}
> displearchable = Solrizer::Descriptor.new(:integer, :indexed, :stored)
> Solrizer.insert_field(solr_doc, 'some_count', 45, displearchable)
=> {"some_count_isi"=>"45"}
We can override the default indexing methods within Solrizer::DefaultDescriptors
Here's the default behavior:
> solr_doc = {}
> Solrizer.insert_field(solr_doc, 'title', 'foobar', :facetable)
=> {"title_sim"=>["foobar"]}
But let's override that by redefining :facetable
module Solrizer
module DefaultDescriptors
def self.facetable
Descriptor.new(:string, :indexed, :stored)
end
end
end
Now, :facetable
will return something different:
> 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
Now, set Solrizer's field mapper to use our new module:
> solr_doc = {}
> Solrizer::FieldMapper.descriptors = [MyMappers]
=> [MyMappers]
> Solrizer.insert_field(solr_doc, 'title', 'foobar', :mapper_one)
=> {"title_ssi"=>"foobar"}
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") { ... }
Matt Zumwalt ("MediaShelf":http://yourmediashelf.com)
Copyright (c) 2010 Matt Zumwalt. See LICENSE for details.
FAQs
Unknown package
We found that solrizer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.