Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

solr_mapper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solr_mapper

  • 0.1.91
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= SolrMapper

A Ruby Object Document Mapper for the Apache Foundation's Solr search platform

== Installing

gem install solr_mapper

== Examples

=== Model require 'solr_mapper' include SolrMapper

class Stuff include SolrDocument bind_service_url 'http://localhost:8080/solr/stuff' limit_page_size 25

belongs_to :thing

end

class Widget include SolrDocument bind_service_url 'http://localhost:8080/solr/widget' limit_page_size 15

belongs_to :thing

end

class Thing include SolrDocument

# base urls can also be defined by rails environments
bind_service_url({
  :development => 'http://somehost/solr_thing',
  :test => 'http://localhost:8080/solr_thing',
  :production => 'http://livebox/solr/thing'
})

limit_page_size 10

has_many :stuffs
has_one :widget

end

=== Auto Generated IDs

as of 0.1.9 you can cause a document to create a UUID id for new objects with:

class Stuff include SolrDocument

# tells solr_mapper to generate the id
auto_generate_id

bind_service_url 'http://localhost:8080/solr/stuff'

end

=== Reading

thing = Thing.find(1)

puts thing.widget.name

thing.stuffs.each do |stuff| puts stuff.name end

=== Querying

searched_things = Thing.query('sample')

a more structured query with a hash

queried_things = Thing.query({:upc_code => '1234567'})

searched_things = Thing.query('name:sample')

=== Writing

thing = Thing.new({:_id => 2, :content => 'sample content'}) thing.save()

=== Writing Related Objects

thing = Thing.new({:_id => 2, :content => 'sample content'}) thing.stuffs << Stuff.new({:_id => 10, :content => 'sample stuff'})

=== Paged Queries

will_paginate page returned. :rows overrides the @per_page setting

with a search string

page = Thing.paginate(':', :rows => 5) puts page.total_pages puts page.count

page = Thing.paginate({:name => 'Sample Name'}, {:rows => 5}) puts page.total_pages puts page.count

=== Deleting

destroys thing from index

Thing.find(1).destroy

stuff = Stuffs.find(3)

deletes reference and destroys stuff from index

Thing.find(2).stuffs.destroy(stuff)

== Copyright

Copyright 2010 The Skunkworx.

FAQs

Package last updated on 29 Dec 2010

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc